|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #50572 <?xml Header not Special Cased
Submitted: 2009-12-25 00:14 UTC Modified: 2009-12-25 00:33 UTC
From: rarpsl at banet dot net Assigned:
Status: Not a bug Package: Feature/Change Request
PHP Version: 5.2.12 OS: PHP
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.
Block user comment
Status: Assign to:
Bug Type:
From: rarpsl at banet dot net
New email:
PHP Version: OS:


 [2009-12-25 00:14 UTC] rarpsl at banet dot net
For over 6 years (or more) PHP has refused to accept a valid XHTML pages that begin with the a <?xml version="1.0" encoding="utf-8"?> tag. While this bug can be worked around by using an echo command to output the tag, this makes the code non-compliant with verifiers that do not see the echo'ed tag but only the PHP code itself.

Since the first line in an XHTML page can be the <?xml tag (which is not valid anywhere else) the PHP interpreter should be able to parse the tag and then accept/ignore it so long as it is the first thing encountered. If it is not the first line, then the current trap code can handle it as it currently does when it is validly placed.

Reproduce code:
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<html xmlns="" xml:lang="en" lang="en">

Expected result:
A display of my PHP Page (as would occur without the <?xml tag).

Actual result:
Parse error: syntax error, unexpected T_STRING in /home/gjzvtbxe/public_html/test3.php on line 1


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-25 00:19 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

What about <?xsl ? what about PHP scripts starting with <?xml_foo();?> ?

Adding this exception is not possible in a sane way.
 [2009-12-25 00:33 UTC]
Or the obvious solution, don't use short_tags.
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Jan 19 21:03:36 2022 UTC