php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #7668 Unexpected change in behavior of { within a string
Submitted: 2000-11-06 21:05 UTC Modified: 2001-01-22 21:44 UTC
From: ray at dasyp dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: 4.0.3pl1 OS: Win NT 4.0 SP6
Private report: No CVE-ID: None
 [2000-11-06 21:05 UTC] ray at dasyp dot com
I had a script running fine under PHP 3.x and 4.0.0, but after upgrading to the latest version (4.04dev), I had some problems.  

Following is an example of the problem:

<?php
$string = "Test String";
echo "This is a {Test} {$string}";
?>

The code above when executed under an older version of the 4.x or 3.x series will produce the following output:

This is a {Test} {Test String}

but under 4.04dev it produces:

This is a {Test} Test String

note the the {} characters are missing around "Test String".  This is causing a problem in an SQL statement.  I have found that escaping the first { character will solve the problem, hence:

<?php
$string = "Test String";
echo "This is a {Test} \{$string}";
?>

will produce:

This is a {Test} {Test String}

Please note that only the initial { character needs to be escaped.

This is my first bug report to PHP and have the suspicion that this isn't actually a bug and perhaps a mistake on my part.  I know that the {} characters are used for delimiting code blocks, but I don't know what their significance would be in a string.  The fact that PHP will expand variables within strings (like perl) adds a little to the puzzle.  Since this behavior seems new to me I thought I would send it in just in case.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-11-06 22:03 UTC] jmoore@php.net
a note from Ignacio Vazquez-Abrams  
----------------------------------- 
see http://www.php.net/version4/incompatibilities.php, item 5. Could
somebody please change this to a documentation problem, as there should
probably be a link from the documentation page?

-- 
Ignacio Vazquez-Abrams  <ignacio@openservices.net>


 [2001-01-22 21:44 UTC] jimw@php.net
this has been added to the documentation.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Tue May 06 12:01:29 2025 UTC