note 45907 added to language.functions

From: Date: Thu, 23 Sep 2004 08:38:39 +0000
Subject: note 45907 added to language.functions
Groups: php.notes 
Request: Send a blank email to php-notes+get-77230@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/language.functions.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+45907 Delete -- http://master.php.net/manage/user-notes.php?action=delete+45907&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+45907&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#77230) next »