note 77022 added to language.oop5.basic
| From: | mep_eisen at web dot de | Date: | Fri, 10 Aug 2007 13:06:52 +0000 |
| Subject: | note 77022 added to language.oop5.basic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-129403@lists.php.net to get a copy of this message | ||
referring to steven's post:
****
Perhaps this is because =& statements join the 2 variable names in the symbol table, whereas =
statements applied to objects simply create a new independent entry in the symbol table that simply
points to the same location as other entries. I don't know for sure - I don't think this
behavior is documented in the PHP manual, so perhaps somebody with more knowledge of PHP's
internals can clarify what is going on.
****
lets talk about
a =& b;
b = c;
PHP internally marks a to be a reference to b. If You reassign b PHP does not update a. But if you
access a once more PHP looks at the current value of b (now containing c).
Both statements (a=b and a=&b) seem to do the same but they don't. However this changed for
objects from PHP4 to PHP5. Where PHP4 needed this operator to avoid object cloning, PHP5 does not
need it.
It is explained in chapter 21 (References Explained). It's important to understand that a
becomes a reference and the following code will not modify b:
a =& b;
a =& c;
----
Server IP: 69.147.83.197
Probable Submitter: 195.200.34.50
----
Manual Page -- http://www.php.net/manual/en/language.oop5.basic.php
Edit -- https://master.php.net/note/edit/77022
Del: integrated -- https://master.php.net/note/delete/77022/integrated
Del: useless -- https://master.php.net/note/delete/77022/useless
Del: bad code -- https://master.php.net/note/delete/77022/bad+code
Del: spam -- https://master.php.net/note/delete/77022/spam
Del: non-english -- https://master.php.net/note/delete/77022/non-english
Del: in docs -- https://master.php.net/note/delete/77022/in+docs
Del: other reasons-- https://master.php.net/note/delete/77022
Reject -- https://master.php.net/note/reject/77022
Search -- https://master.php.net/manage/user-notes.php