php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #24825 <?xml tag mistaken for <?php
Submitted: 2003-07-27 00:07 UTC Modified: 2003-07-27 03:06 UTC
Votes:1
Avg. Score:4.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: drbezborodow at webpathways dot com Assigned:
Status: Wont fix Package: Feature/Change Request
PHP Version: 4.3.2 OS: UNIX
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: drbezborodow at webpathways dot com
New email:
PHP Version: OS:

 

 [2003-07-27 00:07 UTC] drbezborodow at webpathways dot com
Description:
------------
I am not totally sure which version of PHP my web server is using, but I am positive that it is PHP4+. The web host's website is: www.echoechoplus.com

Getting to the point, the PHP server mistakes this tag:
<?xml version="1.0" encoding="iso-8859-1"?>
for the opening and closing of <?php and ?>

The truth is that the designers overlooked (as is understandable in such a huge project) the fact that there are other technologies out there other than PHP.

The server belives that <?xml is really <?php so it says, "sorry, you have made an error. We can't show you this page."

The fact is: if I said, "I wan't apples", the server shouldn't say, "sorry, you spelt oranges incorrectly, please try again"! ;)

A temporary workaround for this problem is VERY simple:

<?php print "<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>" ?>

Reproduce code:
---------------
Create a file named whatever you like with the php extension (ie whatever.php).

In this document, put these XHTML tags in line one, save it and then run the page on a PHP server:

<?xml version="1.0" encoding="iso-8859-1"?>
<!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">

Expected result:
----------------
The tag would have been as normal:
<?xml version="1.0" encoding="iso-8859-1"?>

The PHP Engine should have had nothing to do with this tag. It is an XML tag, but the server thought it was the beginning and end of a PHP script. IE: <?php /*content*/ ?>

Actual result:
--------------
Parse error: parse error in /home/hbsast/harriscoaches.com.au/index.php on line 1

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-27 00:51 UTC] pollita@php.net
I completely sympathize with what you're saying, however this is a behavior which is not (directly) going to change.  Allow me to explain why.

What's catching the '<?xml' tag is actually the scan for the short_open_tag version of '<?'.   When this type of open tag was first created, you're absolutely right, not enough attention was paid to the world outside of PHP.  

In the designers defense, XML was a much smaller blip on the radar at the time, and creating XML documents from PHP sources was not a priority.

It is precisely because of this ambiguity that the long open tag was devised.  However, in the interest of maintaining compatability with preexisting scripts, the short open tag was neither removed, nor was it modified to require a space between it and instruction code.

If your hosting provider allows you to modify php.ini options I'd recommend turning short_open_tags off.  With apache this can even be done on a per-virtualserver/per-directory basis using:

php_flag short_open_tags off

If not, I'm afraid your only option until (if?) the short open tag is fully disabled (don't hold your breath) is to use the echo "<?xml"; hack you mentioned.

Sorry I couldn't give you a better response, and thank you for using PHP.
 [2003-07-27 01:34 UTC] drbezborodow at webpathways dot com
Thank you very much for your response. I posted my bug report at phpbuilder.com and they basically laughed at me. I had to explain that I am a new user of PHP and havn't been around to see previous versions.

Where may I find more specific information about this "php_flag short_open_tags off", that you mentioned?

- Damien Bezborodow
 [2003-07-27 03:06 UTC] magnus@php.net
Have a look at the manual:
http://www.php.net/configuration.changes
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 25 17:01:31 2024 UTC