note 40846 added to language.references.return

From: Date: Wed, 17 Mar 2004 00:58:02 +0000
Subject: note 40846 added to language.references.return
Groups: php.notes 
Request: Send a blank email to php-notes+get-66932@lists.php.net to get a copy of this message
Be careful when using tinary operation condition?value1:value2 See the following code: $a=1; function &foo() { global $a; return isset($a)?$a:null; } $b=&foo(); echo $b; // shows 1 $b=2; echo $a; // shows 1 (not 2! because $b got a copy of $a) To let $b be a reference to $a, use "if..then.." in the function. ---- Manual Page -- http://www.php.net/manual/en/language.references.return.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+40846 Delete -- http://master.php.net/manage/user-notes.php?action=delete+40846&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+40846&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#66932) next »