When I read the source of Codeigniter, I found a function located in file:system/codeigniter/comm.php like that:
/**
* Instantiate Class
*
* Returns a new class object by reference, used by load_class() and the DB class.
* Required to retain PHP 4 compatibility and also not make PHP 5.3 cry.
*
* Use: $obj =& instantiate_class(new Foo());
*/
function &instantiate_class(&$class_object)
{
return $class_object;
}
I can’t undestand it well, and I need more details about the compatibility things. Thanks.
update: Codeigniter version is 1.7.2
The function and it’s example use in question is totally bogus:
That’s the same as writing:
Which is the way that needed to be done in PHP 4.
Since PHP 5, you can just write:
as you might know.
Actually, as you, I do not see any use of the function just for the sole purpose that it’s superflous. It might have had some need in the past (when it had some other definition). I can only assume about it’s existance, most likely that the developer had problems to understand references/aliasing in PHP which is commonly not well understood.
Edit: As KingCrunch pointed out, there is a need for this function if you would like to glue PHP 4 with PHP 5.3 code, because it will prevent strict standards warnings in PHP 5.3. So instead of the PHP 4 (potentially needed)
This must be written as
Which hides away the “Assigning the return value of new by reference is deprecated” warning and allows to code in a PHP 4 style for a PHP 5.3 environment.
Hope this helps you with your software archaeology.