php.net |  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
Votes:2
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
 [2015-12-17 19:04 UTC] daniel dot korner at tu-dortmund dot de
Description:
------------
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).


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-12-19 16:46 UTC] ajf@php.net
Looks like this has been broken since 5.4: https://3v4l.org/kuLmD
 [2015-12-19 17:02 UTC] ajf@php.net
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] rasmus@php.net
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] krakjoe@php.net
-Status: Open +Status: Not a bug
 [2016-03-26 12:22 UTC] krakjoe@php.net
As explained, this isn't a bug.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Thu Jul 18 00:01:25 2019 UTC