php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60540 nowdoc & heredoc definition fails on leaving scripts without php end-tag
Submitted: 2011-12-15 22:14 UTC Modified: 2011-12-18 17:00 UTC
From: constantine dot exelsior at gmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.8 OS: all
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: constantine dot exelsior at gmail dot com
New email:
PHP Version: OS:

 

 [2011-12-15 22:14 UTC] constantine dot exelsior at gmail dot com
Description:
------------
Scripts explicitly started with <?php, but leaved without an ending ?> having 
nowdoc or heredoc definitions inside will result in an syntax error.

Full Error description:
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or 
T_END_HEREDOC or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in <FILE> on line 
<NUMBER>

tested environment:
Zend Server Community Edition
PHP Version 5.3.8-ZS5.5.0

Workarround Solution:
Simply close the <?php on scripts having nowdoc or heredoc definitions.

In bigger projects the most developer leaved any scripts arround without an 
closing php-tag as usual to prevent printing out blank spaces / lines to the 
client.

Test script:
---------------
<?php
echo <<<'EOT'
<b>test</b>
EOT;

Expected result:
----------------
<b>test</b>

Actual result:
--------------
Parse error: syntax error, unexpected $end, expecting T_VARIABLE or T_END_HEREDOC 
or T_DOLLAR_OPEN_CURLY_BRACES or T_CURLY_OPEN in C:\Program Files 
(x86)\Zend\Apache2\htdocs\bam.php on line 4

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-12-18 17:00 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-12-18 17:00 UTC] felipe@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

As says the documentation:
"The closing delimiter (possibly followed by a semicolon) must also be followed by a newline."

Just put a newline after the heredoc/nowdoc closing delimiter.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 13 20:01:33 2025 UTC