php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #55345 comment / php endtag
Submitted: 2011-08-02 11:05 UTC Modified: 2011-08-02 11:20 UTC
From: mac_doggie at hotmail dot com Assigned:
Status: Not a bug Package: Scripting Engine problem
PHP Version: 5.3SVN-2011-08-02 (SVN) OS: Windows 7 64-bits
Private report: No CVE-ID: None
 [2011-08-02 11:05 UTC] mac_doggie at hotmail dot com
Description:
------------
When my source contains this code:

<?php
// $DOMDoc = new DOMDocument();
// $DOMDoc->loadXML("<?xml version=\"1.0\" encoding=\"utf-8\"?><annotations><annotation><type>Goal</type><datetime>12-07-2011 14:05:03</datetime></annotation><annotation><type>Corner</type><datetime>12-07-2011 14:09:33</datetime></annotation></annotations>");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<request>";
?>

it will generate a parse error unexpected T_STRING at the echo command...
If I remove the comment the error is resolved. The cause of this lies in the php endtag ?> witch is found in the comment (in this case this is not even the php endtag but an xml endtag...) Putting a space in between ? > is enough to make it work again, but I still think of this behaviour as a bug. 


Test script:
---------------
not working:
<?php
// $DOMDoc = new DOMDocument();
// $DOMDoc->loadXML("<?xml version=\"1.0\" encoding=\"utf-8\"?><annotations><annotation><type>Goal</type><datetime>12-07-2011 14:05:03</datetime></annotation><annotation><type>Corner</type><datetime>12-07-2011 14:09:33</datetime></annotation></annotations>");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<request>";
?>

working (space between ? and >):
<?php
// $DOMDoc = new DOMDocument();
// $DOMDoc->loadXML("<?xml version=\"1.0\" encoding=\"utf-8\"? ><annotations><annotation><type>Goal</type><datetime>12-07-2011 14:05:03</datetime></annotation><annotation><type>Corner</type><datetime>12-07-2011 14:09:33</datetime></annotation></annotations>");

echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<request>";
?>

Expected result:
----------------
<?xml version=\"1.0\" encoding=\"utf-8\"?>
<request>



Actual result:
--------------
<br />
<b>Parse error</b>:  syntax error, unexpected T_STRING in <b>/usr/big_disk/www/Rogier/voetbal_applicatie/php/main.php</b> on line <b>5</b><br />

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2011-08-02 11:20 UTC] pajoye@php.net
-Status: Open +Status: Bogus
 [2011-08-02 11:20 UTC] pajoye@php.net
Disable the short tag and it will work.
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 27 13:00:02 2025 UTC