note 26048 deleted from language.variables.scope by aidan
| From: | aidan@php.net | Date: | Sun, 04 Jul 2004 02:50:37 +0000 |
| Subject: | note 26048 deleted from language.variables.scope by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72504@lists.php.net to get a copy of this message | ||
Note Submitter: mu at despammed dot com
----
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();
?>