Using 'global $GLOBALS' works, though. 

On a related note, $GLOBALS and superglobals in general are acting a bit
weird recently. I just cvs updated and rebuilt HEAD and this modified
version of your script shows some oddness:

<?php

function foo(){
    global $GLOBALS;
    $GLOBALS['foo']='bar';
}
function bar(){
    global $GLOBALS;
    echo $GLOBALS['foo'];
}
foo();
bar();

print_r($GLOBALS);

?>

Output on my machine:

barArray
(
    [GLOBALS] => Array
 *RECURSION*
    [_POST] => Array
        (
        )

    [_GET] => Array
        (
        )

    [_COOKIE] => Array
        (
        )

    [_FILES] => Array
        (
        )

    [foo] => bar
)

$_SERVER isn't getting into GLOBALS and isn't populated at all. My
variables_order says "GPCS", but doing a var_dump($_SERVER) raises an
E_NOTICE and gives me NULL.

J


Sebastian Bergmann wrote:

>   Notice: Undefined variable: GLOBALS in E:\test.php on line 7
> 
>     1 <?php
>     2 function foo() {
>     3   $GLOBALS['foo'] = 'bar';
>     4 }
>     5
>     6 function bar() {
>     7   echo $GLOBALS['foo'];
>     8 }
>     9
>    10 foo();
>    11 bar();
>    12 ?>
> 


-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to