|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2004-12-30 02:57 UTC] nmuhayimana at semanticdesigns dot com
Description:
------------
Php suppresses the backslash before left curly brace using
"action at distance", violating the "principle of least surprise".
Apparently the backslash is suppressed if there is any non-escaped dollar sign any where in the string.
Reproduce code:
---------------
<?php
echo ("$ \{ \n");
echo (" \{ $\n");
echo (" \{$ \n");
echo (" $\{ \n");
echo (" \$\{ \n");
echo (" \{\$ \n");
echo ("\$ \{ \n");
echo (" \{ \$\n");
echo ("% \{ \n");
?>
Expected result:
----------------
$ \{
\{ $
{$
$\{
$\{
\{$
$ \{
\{ $
% \{
Actual result:
--------------
$ {
{ $
{$
${
$\{
\{$
$ \{
\{ $
% \{
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 13:00:01 2025 UTC |
I think there's an omission in ST_IN_SCRIPTING state backshlash handling (around line 1525 of lex file) - unlike ST_DOUBLE_QUOTES state, it does not convert \{ to {. I think they should be brought together, though I'm not sure which one should win - should \{ be left as is or translated to {?All it needs is just one case '{': in the ST_IN_SCRIPTING state's quoted string handling ?.