Bug #12278 Updated: variable variable inside a string
| From: | zak@php.net | Date: | Fri, 20 Jul 2001 18:14:24 +0000 |
| Subject: | Bug #12278 Updated: variable variable inside a string | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-60426@lists.php.net to get a copy of this message | ||
ID: 12278
Updated by: zak
Reported By: dardo@uol.com.ar
Old Status: Open
Status: Assigned
Bug Type: Output Control
Operating System: independant
PHP Version: 4.0.6
New Comment:
Are you sure that the output of:
<?php
$foo1="nonsense";
$foo2="foo1";
print "$$foo2";
?>
is: $foo2
Under PHP 4.0.6 (Win2k and Linux) the script generates $foo1 when I run it.
From looking at the parser, this does not seem to be an error - at most just an omission.
Perhaps one of the developers could comment? I don't know if the behavior needs to be changed
or just documented.
I would **guess** that we could extend the lexer to handle this by adding something like:
<ST_DOUBLE_QUOTES,ST_BACKQUOTE,ST_HEREDOC>"$$" {
yy_push_state(ST_LOOKING_FOR_VARNAME);
return T_VARIABLE;
}
However, I have not tested it and really have no idea what I am doing! :)
Previous Comments:
------------------------------------------------------------------------
[2001-07-20 08:15:32] dardo@uol.com.ar
<?php
$foo1="nonsense";
$foo2="foo1";
print "$$foo2";
?>
THIS programs output $foo2, (IS THIS OK??)
<?php
$foo1="nonsense";
$foo2="foo1";
print "{$$foo2}";
?>
this program outputs nonsense (THIS IS CORRECT)
------------------------------------------------------------------------
Edit this bug report at http://bugs.php.net/?id=12278&edit=1