note 45715 added to language.references.unset

From: Date: Wed, 15 Sep 2004 23:29:42 +0000
Subject: note 45715 added to language.references.unset
Groups: php.notes 
Request: Send a blank email to php-notes+get-76803@lists.php.net to get a copy of this message
Thinking of the value as 'propegating' to the reference variable is probably why it seems counter-intuitive. What is really happening is: $a = 1; //the PHP variable $a now references a value of 1 $b =& $a; // the PHP variable $b now references THE SAME 1 unset($a); /* The PHP varaible $a is now unset (no longer exists). However, the value 1 is still in memory and the PHP variable $b still references it */ in contrast: $a = 2; //$a references memory containing 2 $b = $a; //now $b also references memory containing 2, but it's different memory $a = 3; //$a now has a value of 3, while $b still has it's separate value of 2 ---- Manual Page -- http://www.php.net/manual/en/language.references.unset.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45715 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45715&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45715&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#76803) next »