note 63499 deleted from language.variables.scope by nlopess

From: Date: Wed, 22 Mar 2006 23:46:52 +0000
Subject: note 63499 deleted from language.variables.scope by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-106400@lists.php.net to get a copy of this message
Note Submitter: ---- About more complex situation using global variables.. Let's say we have two files: a.php <?php function a() { include("b.php"); } a(); ?> b.php <?php $b = "something"; function b() { global $b; $b = "something new"; } b(); echo $b; ?> You could expect that this script will return "something new" but no, it will return "something". To make it working properly, you must add global keyword in $b definition, in above example it will be: global $b; $b = "something";

« previous php.notes (#106400) next »