note 32403 added to language.variables.scope

From: Date: Tue, 27 May 2003 03:02:45 +0000
Subject: note 32403 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-49057@lists.php.net to get a copy of this message
scope after register globals turn off is not so clear ! just to clarify things to newbie function createAglobal(){ global $var $var = "value"; } //you MUST call the function to use the global $var createAglobal(); echo $var; //you will get value //if you use echo without calling the function you will // get Undefined variable: var error i know it might be // obvious for some but i think a lot of people dont // think that might be there problem function readAglobal(){ global $var; echo "this it my global $var";// will work } createAglobal(); readAglobal(); //will echo this is my global value i do hope you will find this info helful best regards ---- Manual Page -- http://www.php.net/manual/en/language.variables.scope.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+32403 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+32403&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+32403&report=yes

« previous php.notes (#49057) next »