note 41688 deleted from language.references.unset by sean

From: Date: Wed, 31 Aug 2005 17:18:35 +0000
Subject: note 41688 deleted from language.references.unset by sean
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-94532@lists.php.net to get a copy of this message
Note Submitter: bishop ---- The unset() behaviour on a referenced variable is very strange and quite counter-intuitive. Consider: <?php $orig = 1; $ref = &$orig; // ref is &int(1) unset($orig); // ref is int(1) // NOTE the reference is gone, but the content remains ?> A small workaround is to null your variables, then to unset them. Eg: <?php $orig = null; unset($orig); ?> This will at least prevent the original value from propogating to the uncoupled reference.

« previous php.notes (#94532) next »