Page 1 of 1

Weird behavior with globals

Posted: Sun May 25, 2008 4:28 pm
by mattalexx
Can anyone explain why this variable is registering in the $GLOBALS array? Register globals is off on the server.

Code: Select all

$foo = new stdClass();
var_dump($GLOBALS['foo']);
print ini_get("register_globals");
// Outputs:
//    object(stdClass)#5 (0) {
//    }
//    Off

Re: Weird behavior with globals

Posted: Mon May 26, 2008 2:14 am
by hansford
It displays when I run it on my server running php 5 as well with globals turned off. Maybe its because stdClass is the base class for php.

Re: Weird behavior with globals

Posted: Mon May 26, 2008 3:22 pm
by mattalexx
I don't think that's the reason. I replaced my own class name for stdClass for the sake of this example..

Code: Select all

class foobar {}
$foobar = new foobar;
var_dump($GLOBALS['foobar']);
var_dump(ini_get("register_globals"));
 
// object(foobar)#1 (0) {
// }
// string(0) ""