[thelist] php operator =&

Mattias Thorslund mattias at thorslund.us
Mon Jun 12 14:46:15 CDT 2006


Sarah Adams wrote:
> I'm helping someone out with some PHP code, and I keep seeing them using
> the operator "=&", which AFAIK is not a PHP operator... but it seems to
> work fine, as though it were a simple assignment operator (i.e. "=").
>
> Before I go telling him that he shouldn't be using it (for the sake of
> code readability, at least), does someone know of some obscure part of
> the PHP docs that mentions this operator? Or perhaps he's confusing it
> with an operator from some other language?
>
>   

That's the assign-by-reference operator. In PHP 4, the = operator will
copy data, even objects, rather than referencing them. A source of
confusion to beginners for sure. I think that's what has changed in PHP
5: the = operator works more similar to other languages.

http://www.php.net/manual/en/language.references.php



More information about the thelist mailing list