note 12701 deleted from language.references.whatdo by colder
| From: | colder@php.net | Date: | Sat, 24 Feb 2007 11:44:26 +0000 |
| Subject: | note 12701 deleted from language.references.whatdo by colder | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-123817@lists.php.net to get a copy of this message | ||
Note Submitter: pbaltz at NO_SPAM dot cs dot NO_SPAM dot wisc dot edu
----
Just a note for others who may run into this. When the manual says that references are bound to the
same copy of the content, it means exactly that.
So doing something like this,
$a = 1;
$b =& $a;
$b = 2;
print "$a $b";
will print '2 2'. This can be frustrating to track down if, like me, you are used to Perl
where you explicitly dereference refrences. Since $a and $b both reference the same data, changing
either, changes both.
It may be obvious to others, but if you are familiar with pointers or Perl references the automatic
dereferencing can be confusing if you forget about it.