From:             [EMAIL PROTECTED]
Operating system: win2k
PHP version:      4.1.0
PHP Bug Type:     Scripting Engine problem
Bug description:  superglobals does not work with dynamic vars in functions

See the attached example. The first print_r() in the
function does not print out anything, while the second 
prints out the contents of $_GET. I have set $_GET to a
dummy array to let you test without a server.

Conclusion: dynamic names does not work for superglobals
in functions (I have also tested them in methods, but
these handled the same as functions...). Though
dynamic names work in global scope for superglobals...

<?php

$_GET = array("aa");

$method = "_GET";
$var = $$method;
echo "\n$method vars in global scope:\n";
print_r($var); // prints out the array

function test ()
{
    $method = "_GET";
    $var = $$method;
    echo "\n$method vars in test func:\n";
    print_r($var); // prints out nothing
    
    echo "\n_GET vars in test func:\n";
    $var = $_GET;
    print_r($var); // prints out the array
    
}

test();

?>
-- 
Edit bug report at http://bugs.php.net/?id=15810&edit=1
-- 
Fixed in CVS:        http://bugs.php.net/fix.php?id=15810&r=fixedcvs
Fixed in release:    http://bugs.php.net/fix.php?id=15810&r=alreadyfixed
Need backtrace:      http://bugs.php.net/fix.php?id=15810&r=needtrace
Try newer version:   http://bugs.php.net/fix.php?id=15810&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=15810&r=support
Expected behavior:   http://bugs.php.net/fix.php?id=15810&r=notwrong
Not enough info:     http://bugs.php.net/fix.php?id=15810&r=notenoughinfo
Submitted twice:     http://bugs.php.net/fix.php?id=15810&r=submittedtwice

Reply via email to