php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51550 'Open php' tag at end of file causes 'syntax error, unexpected $end'
Submitted: 2010-04-13 15:40 UTC Modified: 2010-04-13 16:24 UTC
From: daan at react dot com Assigned: degeberg (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.2.13 OS: Debian Etch
Private report: No CVE-ID: None
 [2010-04-13 15:40 UTC] daan at react dot com
Description:
------------
This probably is a known effect, but I will just open a bug so it can be documented as such:

When you end a file with a PHP open tag '<?php', and there is no character beyond the tag the parser chokes with an 'unexpected $end' parse error.

Curiously, a short tag '<?' (if enabled) used in such a way raises no error.

This effect is of course also seen when you eval a string containing an PHP open tag at the end of the string. (from there I originally stumbled on this behaviour)

In PHP 5.3 the code behaves as expected, so someone probably already spotted this one, or fixed the parser to be less nitty.

Test script:
---------------
<?php

Expected result:
----------------
Nothin

Actual result:
--------------
Parse error: syntax error, unexpected $end in test.php on line 1

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-13 16:10 UTC] johannes@php.net
-Package: Scripting Engine problem +Package: Documentation problem
 [2010-04-13 16:10 UTC] johannes@php.net
This is fixed in 5.3 with a new parser. This won't be fixed in 5.2. Maybe the doc team wants to add it to the documentation.
 [2010-04-13 16:23 UTC] degeberg@php.net
Automatic comment from SVN on behalf of degeberg
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=297962
Log: Fixed PHP bug #51550 ('Open php' tag at end of file causes 'syntax error, unexpected ')
 [2010-04-13 16:23 UTC] degeberg@php.net
-Status: Open +Status: Closed -Package: Documentation problem +Package: Scripting Engine problem -Assigned To: +Assigned To: degeberg
 [2010-04-13 16:23 UTC] degeberg@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2010-04-13 16:24 UTC] degeberg@php.net
-Package: Scripting Engine problem +Package: Documentation problem
 [2010-04-13 16:24 UTC] degeberg@php.net
Oops. Dunno how I got the package changed as well.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Apr 19 06:01:29 2024 UTC