PHP 8.5.0 Alpha 1 available for testing

Voting

: max(nine, four)?
(Example: nine)

The Note You're Voting On

dfoesch at cs dot nmsu dot edu
23 years ago
English explaination of why you do: $xml = & new xml();

Ok, when PHP executes "new xml()" it creates an anonymous variable (one that you can't reference with any name) which it then runs the constructor function on. Ok, now once that's done, it then assigns by VALUE in the example above. This means that that lovely pointer to your parser is pointing to the anonymous instance of your class, and not the used instance of your class... thus making a "shadow" of all your variables, where assignments inside the parser access different variables than outside the parser. What PHP _SHOULD_ be doing (similar to C++) is have this statement execute such that the assignment is done by REFERENCE, so that you assign the new name to the class that actually got constructed, and not just a copy of the class that you constructed.

If they did it right, this code wouldn't be broken.

<< Back to user notes page

To Top