note 16025 added to language.references.arent

From: Date: Fri, 12 Oct 2001 22:04:44 +0000
Subject: note 16025 added to language.references.arent
Groups: php.notes 
Request: Send a blank email to php-notes+get-18869@lists.php.net to get a copy of this message
As said above references are not pointers. Following example shows a difference between pointers and references. This Code <? $b = 1; $a =& $b; print("<pre>"); print("\$a === \$b: ".(($a === $b) ? "ok" : "failed")."\n"); print("unsetting \$a...\n"); unset($a); print("now \$a is ".(isset($a) ? "set" : "unset")." and \$b is ".(isset($b) ? "set" : "unset")."\n"); print("</pre>"); $b = 1; $a =& $b; print("<pre>"); print("\$a === \$b: ".(($a === $b) ? "ok" : "failed")."\n"); print("unsetting \$b...\n"); unset($b); print("now \$a is ".(isset($a) ? "set" : "unset")." and \$b is ".(isset($b) ? "set" : "unset")."\n"); print("</pre>"); ?> will produce this output: --------- $a === $b: ok unsetting $a... now $a is unset and $b is set $a === $b: ok unsetting $b... now $a is set and $b is unset --------- So you see that $a and $b are identical ($a === $b -> true), but if one of both is unset, the other is not effected. -- http://www.php.net/manual/en/language.references.arent.php http://master.php.net/manage/user-notes.php?action=edit+16025 http://master.php.net/manage/user-notes.php?action=delete+16025 http://master.php.net/manage/user-notes.php?action=reject+16025

« previous php.notes (#18869) next »