php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #5251 Improper interpretation of braces ({}) in quoted strings
Submitted: 2000-06-28 16:48 UTC Modified: 2000-06-28 16:55 UTC
From: pdoyle at cncx dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 2 OS: Solaris 2.5.1
Private report: No CVE-ID: None
 [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).

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-06-28 16:55 UTC] andrei at cvs dot php dot net
That is the consequence of the new functionality that allowes
extended variable access inside quoted strings. Use \{ to obtain
literal brace.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 26 10:01:31 2024 UTC