php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #53672 Parser inconsistency for nowdoc/Heredoc vs. "normal" variable assignment at EOF
Submitted: 2011-01-06 16:36 UTC Modified: 2011-01-06 22:25 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:0 (0.0%)
From: dicugeorge1987 at yahoo dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3.5 OS:
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: dicugeorge1987 at yahoo dot com
New email:
PHP Version: OS:

 

 [2011-01-06 16:36 UTC] dicugeorge1987 at yahoo dot com
Description:
------------
Nowdocs and heredocs should also be LALR-reduced when EOF follows after T_END_HEREDOC, not only EOL

Test script:
---------------
<?php
$bar = <<<'EOD'
$foo is a variable
EOD;

Expected result:
----------------
$foo is a variable

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 J:\webdev\apache\htdocs\salut2.php on line 4

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-01-06 16:46 UTC] flavius dot as at gmail dot com
Note that this will work though:
<?php
$foo = 'bar';
 [2011-01-06 16:48 UTC] pajoye@php.net
-Operating System: Windows 7 64bit +Operating System:
 [2011-01-06 22:25 UTC] felipe@php.net
-Status: Open +Status: Bogus
 [2011-01-06 22:25 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

This is expected. The documentation states "The closing delimiter (possibly followed by a semicolon) must also be followed by a newline."

http://docs.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 09:01:26 2024 UTC