Search code examples
phpcodeignitercodeigniter-urlcodeigniter-routing

CodeIgniter - & operator


What exactly does the following line of code doing:

$config = &get_config();

Is & operator passing by reference? Also is get_config() a CodeIgniter helper? I couldn't Google the explanation.


Solution

  • As Konrad Rudolph said here: https://stackoverflow.com/a/3957588/837765

    The & operator tells PHP not to copy the array when passing it to the function. Instead, a reference to the array is passed into the function, thus the function modifies the original array instead of a copy.

    get_config() loads the main config.php file in an array and you modify the returns array directly with the & operator.

    It's not a helper. Take a look here (to find the get_config() function) : http://www.8tiny.com/source/codeigniter/nav.html?_functions/index.html