php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #68033 nowdoc,heredoc doesn't work with .=
Submitted: 2014-09-17 05:08 UTC Modified: 2014-09-17 23:03 UTC
From: jmichae3 at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.6.0 OS: win7ult64sp1retail
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: jmichae3 at yahoo dot com
New email:
PHP Version: OS:

 

 [2014-09-17 05:08 UTC] jmichae3 at yahoo dot com
Description:
------------
in my menu generation code (not this script, but similar, php acts differently. instead of generating an error (it should not), it fails silently and appends the following PHP source code into the string in addition to the string content itself, up to a certain point.

the HTML output from PHP from the pastebin code ends up being
http://pastebin.com/78Mx80V2
$s .= printbreadcrumbsmenu($xmlArray, $filepath, /*array('LI','USER','USERS','VISITOR','VISITORS'), */true);
            $s .= printbreadcrumbsmenu($xmlArray, $filepath, /*array('MODERATOR','MODERATORS'), */false);
            $s .= printbreadcrumbsmenu($xmlArray, $filepath, /*array('ADMIN','ADMINS','ADMINISTRATOR','ADMINISTRATORS'), */false);
            $s .= printbreadcrumbsmenu($xmlArray, $filepath, /*array('LEADERSHIP','LEADERS','LEADER'), */false);
 
            $s .= "    </div>\n";
            $s .= <<<'EOT'

and

            EOT;
            if ((bool)$isxhtml) {
                $s .= $menuhelptextx;
            } else {
                $s .= $menuhelptext;
            }
            $s .= <<<'EOT'

should not be there in the generated HTML source, those are php functions. it seems like php is ignoring the EOT;


Test script:
---------------
<?php
$s="";
$s.= <<<'EOT'
this is <html lang='en'>
<title>a title</title>
  EOT;
echo $s;
?>

http://pastebin.com/fE5CaVEE for the one mentioned in Description.

Expected result:
----------------
should follow the manual in how it works. should not work just for initialization only but for concatenation, and echo as well, any place where you can use a string.
expected HTML output: http://pastebin.com/SYQ4GSWG

Actual result:
--------------
EOT; ignored and therefore php source code is included into the string including the EOT; (until when?)

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2014-09-17 05:09 UTC] requinix@php.net
-Status: Open +Status: Not a bug
 [2014-09-17 05:09 UTC] requinix@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

http://php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
Big red warning.
 [2014-09-17 22:34 UTC] jmicha3 at yahoo dot com
${'http_prefix'} within the properly formatted nowdoc is not being expanded.
it's broken. please fix. thanks.

if it's at all possible, could the EOT (whatever used) for heredoc, nowdoc please work for beyond just the beginning of a line? I need most of those strings to end with some indentation.
thanks. in fact, I will make it a feature request if it's not already one.
there may be lexer reasons for this, but I need this feature. "" doesn't do this sort of thing anymore, it used to, but no longer, that's broken, no longer works with strings like 
$s="abc
def
ghi
   ";
 [2014-09-17 22:52 UTC] jmichae3 at yahoo dot com
correction to that last statement, multiline "" strings do work. not sure what I was seeing.

d:\www\Jesusnjim>php
<?php
$s=5;
$t=<<<'EOT'
abc${'s'}def$s
EOT;
echo $t;
?>
^Z
abc${'s'}def$s

this is what I am talking about, I suppose I should submit another bug report for this one?
 [2014-09-17 23:03 UTC] aharvey@php.net
That's a nowdoc: they don't interpolate, so that's the expected output. Note the difference between <<<EOT (heredoc; does interpolate) and <<<'EOT' (nowdoc; does not interpolate).
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Wed Oct 07 20:00:02 2026 UTC