php.net |  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
 [2009-12-25 00:14 UTC] rarpsl at banet dot net
Description:
------------
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"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
.
.
.
(etc)

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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

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] rasmus@php.net
Or the obvious solution, don't use short_tags.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 12:01:27 2024 UTC