Hmmm, I saw that before when I tried to write code which is compatible with all
versions of PHP. Something like
<pre>
<?php
if ((str_replace('.','',phpversion())<410)){
define("__GET","HTTP_GET_VARS");
}else{
define("__GET","_GET");
}
echo phpversion()."\n";
var_dump(${__GET}['some']);
function a(){
var_dump(${__GET}['some']);
echo __GET;
}
a();
?>
Output:
4.1.1
string(2) "aa"
NULL
_GET
----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 4:51 PM
Subject: Bug #15810: superglobals does not work with dynamic vars in functions
> 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
>
>
--
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, visit: http://www.php.net/unsub.php