note 39953 added to functions
| From: | woodyu388 at hotmail dot com | Date: | Mon, 16 Feb 2004 22:53:59 +0000 |
| Subject: | note 39953 added to functions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65238@lists.php.net to get a copy of this message | ||
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.
----
Manual Page -- http://www.php.net/manual/en/functions.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+39953
Delete -- http://master.php.net/manage/user-notes.php?action=delete+39953&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+39953&report=yes
Search -- http://master.php.net/manage/user-notes.php