note 45715 deleted from language.references.unset by tomsommer

From: Date: Thu, 16 Sep 2004 10:17:36 +0000
Subject: note 45715 deleted from language.references.unset by tomsommer
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-76813@lists.php.net to get a copy of this message
Note Submitter: pmallett ---- 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

« previous php.notes (#76813) next »