ID: 37263 User updated by: dbeckham at dealnews dot com Reported By: dbeckham at dealnews dot com Status: Open Bug Type: Scripting Engine problem Operating System: Linux (2.6.14) PHP Version: 5.1.2 New Comment:
Here is another example to highlight the problem: php -r '$test = array(array(0,1), array(2,3)); echo "{$test[1][0]}\n";' This should produce the following output: 2 php -r '$test = array(array(0,1), array(2,3)); echo "\{$test[1][0]}\n";' This produces: \{Array[0]} Since curly braces are no longer special characters, should not echo "\{$test[1][0]}\n"; produce the following? \2 Previous Comments: ------------------------------------------------------------------------ [2006-05-01 20:01:32] dbeckham at dealnews dot com I disagree, this *is* a bug. You can't have it both ways, either the curly brace is not a special character and does not need to be escaped, or it is a special character used for complex variables and can be escaped. What you have right now is neither ... it's a special character and removed from the output when used with a complex variable, but if escaped, it's not used with the complex variable and additionally the backslash is added to the output. By the way, my intention was never to produce {$ in the output, but only to make sure the curly brace was output along with the variable. ------------------------------------------------------------------------ [2006-05-01 19:32:26] judas dot iscariote at gmail dot com this is not a bug, it's a behaviour change of the engine. see. http://bugs.php.net/bug.php?id=35527 and the documentation here: "Before PHP 5.1.1, backslash in \{$var} hasn't been printed." "(Use "{\$" to get a literal "{$")." [1] [1] http://php.net/manual/en/language.types.string.php ------------------------------------------------------------------------ [2006-05-01 15:36:29] dbeckham at dealnews dot com Description: ------------ When escaping curly braces in a string, the backslash characters are included in any output. Reproduce code: --------------- <? $test = "test"; echo "\{$test\}\n"; ?> Expected result: ---------------- The above output should be: {test} Actual result: -------------- The actual output is: \{test\} ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37263&edit=1