|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2000-06-28 16:48 UTC] pdoyle at cncx dot com
When the scripting engine encounters a left brace ({) followed by a variable name, it assumes the brace is associated with the variable, and absorbs it and any matching right brace into the variable.
That is,
<?php echo "{$Hello}"; ?>
will produce "" as output, not "{}". Also,
<?php echo "{$Hello there}"; ?>
will produce an error:
Parse error: parse error, expecting `'}'' in /ch/admin.rt/www.admin-dev/html/home/test/test3.cgi on line 2
rather than the expected "{ there}".
I presume this has to do with the improved variable referencing in quoted strings. I noticed this in the context of the IMAP extension, which actually uses curly braces in its function arguments (see imap_open as an example).
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Dec 18 19:00:01 2025 UTC |
That is the consequence of the new functionality that allowes extended variable access inside quoted strings. Use \{ to obtain literal brace.