note 45907 deleted from language.functions by betz
| From: | betz@php.net | Date: | Thu, 23 Sep 2004 10:33:26 +0000 |
| Subject: | note 45907 deleted from language.functions by betz | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-77235@lists.php.net to get a copy of this message | ||
Note Submitter: joshuaditty at cardinal-points dot com
----
I had a bit of trouble trying to declare variables using the $GLOBALS variable, as in:
<?php
global $GLOBALS;
?>
I used a test function to output two variables like so:
<?php
$var1 = "Hello";
$var2 = "World";
function test () {
global $GLOBALS;
echo "TESTING1: ${GLOBALS['var1']} ${GLOBALS['var2']}<br>";
}
test();
?>
But the variables would not output. Testing the $GLOBALS variable, I added the line:
<?php
echo "TESTING2: ".$GLOBALS['var1'] $GLOBALS['var2'];
?>
And not only did that output, but the function started to output, too. Not sure exactly why this
happens, but it seems you have to use the $GLOBALS variable to get it working.
I find that adding the following at the beginning of the file will fix this problem:
<?php
isset($GLOBALS);
?>
Although any function will do the trick.