note 20683 added to function.xml-set-object
| From: | dfoesch at cs dot nmsu dot edu | Date: | Fri, 12 Apr 2002 09:38:39 +0000 |
| Subject: | note 20683 added to function.xml-set-object | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-29150@lists.php.net to get a copy of this message | ||
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.
--
http://www.php.net/manual/en/function.xml-set-object.php
http://master.php.net/manage/user-notes.php?action=edit+20683
http://master.php.net/manage/user-notes.php?action=delete+20683
http://master.php.net/manage/user-notes.php?action=reject+20683