php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #11071 probs displaying backslash with HERE statements
Submitted: 2001-05-23 19:09 UTC Modified: 2004-04-30 10:39 UTC
Votes:1
Avg. Score:1.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:1 (100.0%)
From: simon at studio24 dot net Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.3.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: simon at studio24 dot net
New email:
PHP Version: OS:

 

 [2001-05-23 19:09 UTC] simon at studio24 dot net
hi there,
this may be obscure and I'm not sure if it is a bug but I've experienced a problem with populating a variable with a HERE statement (ie. $variable = <<< EOD). As far as I was aware the variable is supposed to be populated with anything after the first EOD line and before the ending EOD; line.

This HERE statement does not work if you put a slash before a left curly brace ( \{ ) . It's fine with a right curly brace ( \} ). looking at the script below version 1 does not display the first slash, version 2 does (only because I escaped the slash first).

This seems to be a bug, so I hope this is the right place to inform you about it.

best wishes
Simon R Jones

simon@studio24.net
www.studio24.net

Configure command: './configure' '--with-gd' '--enable-track-vars' '--with-apxs=/usr/sbin/apxs' '--enable-sysvsem' '--enable-sysvshm' '--with-zlib' '--prefix=/usr' '--with-config-file-path=/etc/httpd/conf' '--enable-memory-limit' '--with-pgsql=/usr' '--with-db2=/usr' '--with-gdbm=/usr' '--with-ndbm=/usr' '--with-dbase' '--enable-trans-sid' '--with-xml=/usr' '--enable-debugger' '--enable-ftp' '--with-ttf' '--with-jpeg-dir=/usr' '--enable-bcmath' '--with-openssl' '--enable-trans-sid' '--with-mysql=/usr' '--with-xpm-dir=/usr/X11R6' '--with-png-dir=/usr' '--with-imap' '--with-dom' '--with-imap-ssl' '--with-mhash=/usr' '--with-mcrypt=/usr'

example script (online at http://dev.studio24.net/test.php ):

<?

$content .= <<< EOD

<tt>
\{[A-Z0-9][A-Z0-9_]{1,}\} more text \" \ \\ \{ \} \&

</tt>

EOD;

$content2 .= <<< EOD

<tt> 
\\{[A-Z0-9][A-Z0-9_]{1,}\} more text \" \ \\ \{ \} \&
</tt>

EOD;

echo "version 1: $content<br>\n
      version 2: $content2";

?>

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-12 06:47 UTC] yohgaki@php.net
Simpler code for this report.
Heredoc block supposed to parse just like double quoted strings, but it does not.  (PHP4.1.0)

Is this a bug or feature?

?php
echo '<pre>';

$heredoc = <<< EOD
\{
EOD;

$string = "\{";
   
echo "heredoc : $heredoc\n";
echo "string  : $string\n";

?>

 [2001-12-12 08:09 UTC] yohgaki@php.net
PHP Version update
 [2002-08-17 01:34 UTC] kalowsky@php.net
is this still valid in 4.2?
 [2002-09-19 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2004-04-28 15:40 UTC] simon at studio24 dot net
Problem still occurs with PHP 4.3.5 (version updated in edit submission form)

Test script prints:
heredoc : {
string  : \{

I am presuming this is because curly braces can be used to include more complex variables in a heredoc syntax, ie. {$this->var['key']}

See:
http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc

PHP seems to be spotting \{ and treating this as an escaped curly brace, even though there is no matching closing brace.

best wishes,
Simon
 [2004-04-29 23:14 UTC] sniper@php.net
Of course it won't work. It's a feature..

 [2004-04-30 10:39 UTC] simon at studio24 dot net
that's ok then!
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Sep 09 09:01:27 2024 UTC