note 52148 added to language.variables.scope

From: Date: Fri, 22 Apr 2005 09:51:26 +0000
Subject: note 52148 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-88391@lists.php.net to get a copy of this message
Be carefull about nested functions : <?php // won't work : function foo1() { $who = "world"; function bar1() { global $who; echo "Hello $who"; } } // will work : function foo2() { $GLOBALS['who'] = "world"; function bar2() { global $who; echo "Hello $who"; } } // also note, of course : function foo3() { $GLOBALS['who'] = "world"; // won't work echo "Hello $who"; // will work global $who; echo "Hello $who"; } ?> ---- Manual Page -- http://www.php.net/manual/en/language.variables.scope.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52148 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52148&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52148&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52148&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52148&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52148&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52148&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88391) next »