There is a comment on an answer on SO:
Code in answer:
$larry = & $fred;
Comment:
This is deprecated and generates a warning
But I don't think it is correct. Or is it?
So basically the question is:
can I copy a variable to another variable by reference?
Depends on what type variable $fred
is. If it's an object, it will be passed as reference a pointer to the object (thanks NikiC) will be passed as value anyway as of PHP 5, so there is no need to explicitly do it. Thus far, the comment is correct-ish.
For all other variable types, however, passing by reference needs to be explicitly specified and is not deprecated. Although it could be argued that it's usually not good programming practice to use a lot of references in PHP.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With