|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71151 File which contains only "<?php" isn't interpreted
Submitted: 2015-12-17 19:04 UTC Modified: 2016-03-26 12:22 UTC
Avg. Score:2.5 ± 1.5
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: daniel dot korner at tu-dortmund dot de Assigned:
Status: Not a bug Package: *General Issues
PHP Version: 7.0.1 OS: Linux 4.2.5-1-Arch
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
29 - 25 = ?
Subscribe to this entry?

 [2015-12-17 19:04 UTC] daniel dot korner at tu-dortmund dot de
By accident I created a file that only contains "<?php". This file has no space, line break or other character following after the last "p". In this case, the php interpreter does not interpret the file and simply returns the string "<?php".

If I then add a space, line break or other whitespace character after the last "p", the interpreters starts to interpret the .php file correctly and returns an empty string.

I could reproduce this behaviour with PHP 7.0.0 and PHP 7.0.1 but not with PHP 5.6.16 on a Computer running Linux (4.2.5-1-ARCH  x86_64).


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 16:46 UTC]
Looks like this has been broken since 5.4:
 [2015-12-19 17:02 UTC]
The reason you couldn't reproduce it on Linux is probably because it is a UNIX convention to treat newlines (aka LF or \n) as marking the end of a line, not separating lines, and so UNIX text editors tend to add a newline at the end of a file.
 [2015-12-19 23:24 UTC]
The opening tag has always been defined as <?php<whitespace>
where <whitespace> is satisfied by space, tab, \r or \n
It was never just "<?php"
Whether or not <eof> should be considered whitespace seems like a rather philosophical issue rather than a bug.
 [2016-03-26 12:22 UTC]
-Status: Open +Status: Not a bug
 [2016-03-26 12:22 UTC]
As explained, this isn't a bug.
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Oct 23 06:01:24 2020 UTC