Hi Jim,

The code you posted is correct, I never contested that. Read carefully.

<?php
function not_super()
{
var_dump(isset($GLOBALS['GLOBALS']));
$a = array_keys($GLOBALS);
var_dump(isset($a['GLOBALS']));
}
not_super();
?>


run this code, don't read it, you will see output of bool(false), bool(false)

However, the following code works as expected!

<?php
function not_super()
{
   return array_keys($GLOBALS);
}
var_dump(not_super(), array_keys($GLOBALS));
?>

GLOBALS will be present in both arrays.

Very odd behavior.

Greg


Jim Lucas wrote:


actually, it does work and it does exist.

Try using print_r() or

print_r(array_keys($GLOBALS));


and you will see an entry for GLOBALS


mine is located at #13

Jim Lucas

----- Original Message ----- From: "Greg Beaver" <[EMAIL PROTECTED]>
To: "Leif K-Brooks" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Friday, August 01, 2003 12:45 PM
Subject: Re: [PHP] Re: Globals





Try this code:

<?php
function blah() {
 var_dump($GLOBALS['GLOBALS']);

}

blah();
?>

It appears that in a function scope, it doesn't. This is definitely a bug, I'll post it if it hasn't already been noticed.

Greg

Leif K-Brooks wrote:



Greg Beaver wrote:



$GLOBALS does not contain a reference to itself


Yes it does. I just ran the following, and I got "Greg is wrong."

<?php
$foo = 'Greg is wrong.';
echo $GLOBALS['GLOBALS']['GLOBALS']['GLOBALS']['foo'];
?>



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php










Reply via email to