note 13995 modified in language.references.return by irc-html
| From: | irc-html@php.net | Date: | Sat, 19 Jan 2002 20:22:45 +0000 |
| Subject: | note 13995 modified in language.references.return by irc-html | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-25292@lists.php.net to get a copy of this message | ||
Try this for kicks:
function &reference()
{ global $x; $x=FALSE;return $x;}
function inside()
{$x=&reference();print " inside: ".(($x)?"1":"0");}
$x=&reference();print " main x: ".(($x)?"1":"0");
$y=&reference();print " main y: ".(($y)?"1":"0");
inside();
//prints main x:1 main y:0 inside:0
So, umm, be careful with these globals and references combined, as they evidently can get a little
screwy when crossed.
--was--
Try this for kicks:
$db=fetch_database_connection();
print "DB:".$db;
function &reference()
{ global $x; $x=FALSE;return $x;}
function inside()
{$x=&reference();print " inside: ".(($x)?"1":"0");}
$x=&reference();print " main x: ".(($x)?"1":"0");
$y=&reference();print " main y: ".(($y)?"1":"0");
inside();
//prints main x:1 main y:0 inside:0
So, umm, be careful with these globals and references combined, as they evidently can get a little
screwy when crossed.
http://www.php.net/manual/en/language.references.return.php