note 39953 deleted from functions by irchtml
| From: | irchtml@php.net | Date: | Tue, 17 Feb 2004 00:28:43 +0000 |
| Subject: | note 39953 deleted from functions by irchtml | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-65243@lists.php.net to get a copy of this message | ||
Note Submitter: woodyu388@hotmail.com
----
For those of you who have been wondering how to make all global variables accessable from within a
function, this code seems to work.
<?php
function myFunc() {
foreach ($GLOBALS as $key => $value) {
// Note the double $
global $$key;
}
// Insert your function code here
}
?>
This will make all of your global variables available within the scope of the function. Any changes
to the variables within the function will also change the variables on the global level.