Bug #17017: Variable superglobal variable not recognised within function and method
| From: | lennart dot mulder at gmx dot net | Date: | Sun, 05 May 2002 16:58:27 +0000 |
| Subject: | Bug #17017: Variable superglobal variable not recognised within function and method | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-6960@lists.php.net to get a copy of this message | ||
From: lennart.mulder@gmx.net
Operating system: Linux
PHP version: 4.2.0
PHP Bug Type: Variables related
Bug description: Variable superglobal variable not recognised within function and method
Hello :-)
The definition of a variable variable as superglobal works fine when put
in the main coding (i.e. not within a function or method). Example:
<?php
$aVariable = 'GET';
echo ${"_{$aVariable}"};
?>
The system output is: Array
In the next example however, where the same code is put into a function,
the resulting output is a error message instead:
<?php
function aFunction()
{
$aVariable = 'GET';
echo ${"_{$aVariable}"};
}
aFunction();
?>
The system output is: Notice: Undefined variable: _GET in Bestand.php on
line 6.
Also when $_GET has been defined as global (which should not be necessary)
this malfunction remains.
Suggested intermediate solution:
<?php
function aFunction()
{
$aVariable = 'GET';
echo $GLOBALS["_{$aVariable}"];
}
aFunction();
?>
--
Edit bug report at http://bugs.php.net/?id=17017&edit=1
--
Fixed in CVS: http://bugs.php.net/fix.php?id=17017&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=17017&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=17017&r=needtrace
Try newer version: http://bugs.php.net/fix.php?id=17017&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=17017&r=support
Expected behavior: http://bugs.php.net/fix.php?id=17017&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=17017&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=17017&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=17017&r=globals