|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2001-07-20 08:15 UTC] dardo at uol dot com dot 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)
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Nov 05 14:00:01 2025 UTC |
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! :)