note 26048 added to language.variables.scope
| From: | mu at rack1 dot php dot net | Date: | Wed, 16 Oct 2002 09:42:22 +0000 |
| Subject: | note 26048 added to language.variables.scope | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-38152@lists.php.net to get a copy of this message | ||
Do make every variable global in your function, you might try using the line "global
$GLOBALS;", but this won't work. Use this line instead:
foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};}
Example:
<?php
function func()
{
foreach (array_keys($GLOBALS) as $i) {if(!isset(${$i})) global ${$i};}
echo $a;
}
$a = "hello";
func();
?>
--
http://www.php.net/manual/en/language.variables.scope.php
http://master.php.net/manage/user-notes.php?action=edit+26048
http://master.php.net/manage/user-notes.php?action=delete+26048
http://master.php.net/manage/user-notes.php?action=reject+26048