Bug #68033 [Nab]: nowdoc,heredoc doesn't work with .=
| From: | aharvey@php.net | Date: | Wed, 17 Sep 2014 23:03:58 +0000 |
| Subject: | Bug #68033 [Nab]: nowdoc,heredoc doesn't work with .= | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-187582@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68033&edit=1
ID: 68033
Updated by: aharvey@php.net
Reported by: jmichae3 at yahoo dot com
Summary: nowdoc,heredoc doesn't work with .=
Status: Not a bug
Type: Bug
Package: Scripting Engine problem
Operating System: win7ult64sp1retail
PHP Version: 5.6.0
Block user comment: N
Private report: N
New Comment:
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).
Previous Comments:
------------------------------------------------------------------------
[2014-09-17 22:52:28] 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 22:34:04] 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 05:09:37] 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 05:08:06] 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?)
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68033&edit=1