I was just looking at the source code of CodeIgniter, and I came across a couple of things that I cannot understand; I'm not sure what they mean, and since they are mostly similar to one or two characters, this makes it difficult for them to search both google and stackoverflow.
One thing that I have encountered quite a bit is this:
$this->config =& get_config();
I have never come across =& (or basically & ) in PHP before. What does it mean? Are they an instance assignment from get_config to $this->config ? I assume $this->config comes from the declaration at the top of the file where var $config = array(); indicated var $config = array();
I searched for the get_config() function, and found the following line:
function &get_config($replace = array())
Here my question is about the same: what does & mean and what does it do? I see these two things ( & and =& ) in all the main CI files.
Something else that I was curious about was their "style" of comments. Each function starts with a comment block, here is an example:
Is this generated by some plugin or library? It sounds like a lot of hassle to do it manually. I have not tested things like PHPDoc, but could it be something similar (or PHPDoc)? Seems useful if it automatically generates this? Heehee.
To the next question. I see different functions with an underscore prefix. There is an obvious __construct , but there are also functions like _set_default_controller(); and _set_routing(); . Do these underscores have any particular meaning? I know that double underscores are used for something called "magic methods" (I think of __get and __set , since these are the ones I used myself). Do they have a βspecialβ technical meaning or is this pure semantics? Enlighten me if possible.
And last but not least, in the controller core file, I saw this:
class CI_Controller { private static $instance; public function __construct() { self::$instance =& $this;
The line of interest is here self::$instance =& $this; What does it mean? Did he install $this instance of himself (wiiiiiild guess, haha) so we can use $ this? Or does it make no sense? Actually, this is not so, since in the most basic MVC template I use myself for basic sites, I use $ this without any advanced things.
Can someone give you some idea? I would be thankful. Thank you very much in advance.