php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #61723 <?php issues a parse error
Submitted: 2012-04-13 15:27 UTC Modified: 2014-11-18 11:07 UTC
From: lgandras at gmail dot com Assigned: salathe (profile)
Status: Closed Package: Documentation problem
PHP Version: 5.3.10 OS: Centos 6.2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: lgandras at gmail dot com
New email:
PHP Version: OS:

 

 [2012-04-13 15:27 UTC] lgandras at gmail dot com
Description:
------------
"<?php" issues a parse error whereas "<?php " does not. php -r "" is valid in the command line. this is an inconsistent behavior.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-04-14 03:34 UTC] laruence@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

I can not reproduce this.
 [2012-04-14 03:34 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2012-04-14 04:05 UTC] aharvey@php.net
-Status: Feedback +Status: Verified
 [2012-04-14 04:05 UTC] aharvey@php.net
I was able to. You have to be very careful not to have any whitespace after the <?
php — if your editor adds a newline (like vi), then that will cause it to be OK.

What I'm not so sure about is whether this is really a bug: the whitespace at the 
end of the opening tag is really part of the opening tag, so it may just need a 
documentation update to be clearer.

Parser people? What's our expectation here?
 [2012-04-14 04:06 UTC] aharvey@php.net
-Package: Compile Failure +Package: Scripting Engine problem
 [2012-04-14 04:21 UTC] laruence@php.net
@aharvey ah, thanks,  in that case, I would say, this is a rare usage, and a doc 
will be okey.
 [2012-04-14 04:45 UTC] rasmus@php.net
-Status: Verified +Status: Not a bug
 [2012-04-14 04:45 UTC] rasmus@php.net
<?php is an XML PI tag. The full grammar for the tag as defined by the spec is:

PI	   ::=   	'<?' PITarget (S (Char* - (Char* '?>' Char*)))? '?>'

The PITarget in this case is 'php'. The 'S' in the grammar there means 
whitespace. The first whitespace character signifies the end of the PITarget. If 
you have no whitespace you do not have a valid PI tag.
 [2012-04-14 04:59 UTC] aharvey@php.net
-Status: Not a bug +Status: Assigned -Type: Bug +Type: Documentation Problem -Package: Scripting Engine problem +Package: Documentation problem -Assigned To: +Assigned To: aharvey
 [2012-04-14 04:59 UTC] aharvey@php.net
Reopening as a doc bug and assigning to myself -- we could be a little clearer 
about this on the escaping from HTML manual page.
 [2012-04-14 07:04 UTC] aharvey@php.net
Automatic comment from SVN on behalf of aharvey
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=325166
Log: Fix doc bug #61723 (&lt;?php issues a parse error).
 [2012-04-14 07:04 UTC] aharvey@php.net
-Status: Assigned +Status: Closed
 [2012-04-14 07:04 UTC] aharvey@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.


 [2012-04-14 11:14 UTC] salathe@php.net
-Status: Closed +Status: Re-Opened
 [2012-04-14 11:14 UTC] salathe@php.net
I don't think the doc changes reflect reality.

The behaviour is different with/without short_open_tag enabled.

I tried the following with 5.1.0, 5.2.0, 5.3.0 and 5.4.0.

With short_open_tag On:

A file containing only "<?php" issues a Parse Error (unexpected $end/end of 
file) in all four versions.  A file containing only "<?php " executes without 
error in all four versions.

With short_open_tag Off:

A file containing only "<?php" prints that out, there is no Parse Error. A file 
containing only "<?php " executes, as with short_open_tag on, without error in 
all four versions.



The suggestion here would be to get rid of that paragraph in the docs and 
mention that some form of whitespace is always needed after the long opening tag 
to move into "PHP mode".
 [2014-11-18 11:07 UTC] salathe@php.net
-Status: Re-Opened +Status: Closed -Assigned To: aharvey +Assigned To: salathe
 [2014-11-18 11:07 UTC] salathe@php.net
Closing this off. I can live with the current doc.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC