note 95104 added to language.variables.scope

From: Date: Mon, 14 Dec 2009 04:33:05 +0000
Subject: note 95104 added to language.variables.scope
Groups: php.notes 
Request: Send a blank email to php-notes+get-163912@lists.php.net to get a copy of this message
It seems you don't even need to declare a global variable in the global scope. Consider.. <?php function set_global() { GLOBAL $g; $g = "I was not declared in the global scope"; } function read_global() { GLOBAL $g; echo $g; } set_global(); read_global(); ?> displays: I was not declared in the global scope I am maintaining a body of legacy code and before I grasped this I was wasting time fruitlessly searching for variable declarations in the global scope, that just did not exist! Hope this help s/o else. ---- Server IP: 92.48.74.199 Probable Submitter: 82.7.126.163 ---- Manual Page -- http://www.php.net/manual/en/language.variables.scope.php Edit -- https://master.php.net/note/edit/95104 Del: integrated -- https://master.php.net/note/delete/95104/integrated Del: useless -- https://master.php.net/note/delete/95104/useless Del: bad code -- https://master.php.net/note/delete/95104/bad+code Del: spam -- https://master.php.net/note/delete/95104/spam Del: non-english -- https://master.php.net/note/delete/95104/non-english Del: in docs -- https://master.php.net/note/delete/95104/in+docs Del: other reasons-- https://master.php.net/note/delete/95104 Reject -- https://master.php.net/note/reject/95104 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#163912) next »