Bug #15730 Updated: Autoglobal (Variable) Variables within funktions.
| From: | yohgaki@php.net | Date: | Tue, 26 Feb 2002 14:52:53 +0000 |
| Subject: | Bug #15730 Updated: Autoglobal (Variable) Variables within funktions. | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-1079@lists.php.net to get a copy of this message | ||
ID: 15730
Updated by: yohgaki@php.net
Reported By: postings.php.net@hans.spath.de
Status: Open
-Bug Type: Variables related
+Bug Type: Scripting Engine problem
Operating System: Win2k
PHP Version: 4.1.1
New Comment:
It seems PHP(Zend) is looking up local (active) symbol table, since
you are accessing via vairable variable.
Can we fix this?
Previous Comments:
------------------------------------------------------------------------
[2002-02-26 08:45:43] postings.php.net@hans.spath.de
I tried to access the autoglobal variables via the variable variables
'trick'. But that doesn't work within functions.
Examples:
That works:
<?
?><hr><?
$test1 = '_TEST';
$test2 = '_SERVER';
$_TEST = '[test1]';
?><pre><?
var_dump( $test1 );
var_dump( ${'_TEST'} );
var_dump( ${$test1} );
var_dump( ${"$test1"} );
?><hr><?
var_dump( $test2 );
var_dump( ${'_SERVER'} );
var_dump( ${$test2} );
var_dump( ${"$test2"} );
?></pre><hr><?
That doesn't work:
<?
function foolme()
{
?><hr><?
$test1 = '_TEST';
$test2 = '_SERVER';
$_TEST = '[test1]';
?><pre><?
var_dump( $test1 );
var_dump( ${'_TEST'} );
var_dump( ${$test1} );
var_dump( ${"$test1"} );
?><hr><?
var_dump( $test2 );
var_dump( ${'_SERVER'} );
var_dump( ${$test2} );
var_dump( ${"$test2"} );
?></pre><hr><?
}
foolme();
--
I found that, while writing a class for processing html forms:
function __wakeup() {
$method = $this->_method;
$this->_FORM = &${"_$method"};
}
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=15730&edit=1