Doc #70772 [Nab]: nowdoc does not work as documented
| From: | teo8976 at gmail dot com | Date: | Thu, 22 Oct 2015 20:16:04 +0000 |
| Subject: | Doc #70772 [Nab]: nowdoc does not work as documented | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12836@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=70772&edit=1
ID: 70772
User updated by: teo8976 at gmail dot com
Reported by: teo8976 at gmail dot com
Summary: nowdoc does not work as documented
Status: Not a bug
Type: Documentation Problem
Package: *General Issues
PHP Version: Irrelevant
Block user comment: N
Private report: N
New Comment:
I didn't forget to add a newline, I put several. However, I see that the problem is with
3v4l.org (which is where I was testing) which trims them.
Anyway, a more specific error message in the case of a missing newline would probably be better.
Previous Comments:
------------------------------------------------------------------------
[2015-10-22 19:06:10] salathe@php.net
This error occurs when you forget to add a newline* after the closing delimiter. The newline
requirement is mentioned in the Big Red Box on the documentation page linked above, in the heredoc
section.
(* or the website you're using to run the code (here's looking at you 3v4l.org) helpfully
strips training whitespace from the code before execution.)
------------------------------------------------------------------------
[2015-10-22 18:25:28] teo8976 at gmail dot com
Description:
------------
---
From manual page: http://www.php.net/language.types.string
---
The example regarding newdoc syntax is broken.
Test script:
---------------
<?php
$str = <<<'EOD'
Example of string
spanning multiple lines
using nowdoc syntax.
EOD;
Expected result:
----------------
Either the script should work, or it should be replaced with a working example in the docs
Actual result:
--------------
Parse error: syntax error, unexpected end of file, expecting variable (T_VARIABLE) or heredoc end
(T_END_HEREDOC) or ${ (T_DOLLAR_OPEN_CURLY_BRACES) or {$ (T_CURLY_OPEN) in /in/T9Wfr on line 6
The error message varies depending on the version of PHP.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=70772&edit=1