php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #4288 parse error when trying to use <?xml ... ?> declaration
Submitted: 2000-05-01 22:20 UTC Modified: 2000-05-02 00:29 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: hrothgar at techie dot com Assigned:
Status: Closed Package: Scripting Engine problem
PHP Version: 4.0 Release Candidate 1 OS: Linux i586 2.2.14
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: hrothgar at techie dot com
New email:
PHP Version: OS:

 

 [2000-05-01 22:20 UTC] hrothgar at techie dot com
Situation:  I'm trying to use XHTML (HTML meets XML) to build a site.  In my current implementation, I'm trying to use an `include` statement to insert the workings of a header.php file, but for simplification purposes, I've reduced the problem down to a single, *static* file for the parser to chew on.

Consider the file, test.php, to illustrate the problem:

>>>test.php
  <?xml version="1.0" encoding="UTF-8"?>
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>foo</head>
  <body>bar</body>
  </html>
<<<test.php

I get the following parse error when trying to view this:

  Parse error: parse error in /home/httpd/html/test.php on line 1

It appears that the php parser is not respecting the `<?xml` tag as being a non-php tag.  If a non-php `<?*` tag is found, the parser should simply quote the tag instead of just dieing (IMHO).  Thanks

configuration:
  ./configure --with-mysql --with-axps --disable-debug
  apache 1.3.9

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-05-01 23:22 UTC] rasmus at cvs dot php dot net
Edit your php.ini file and turn off the short tags.  Then use <?php ... ?> for your PHP tags.
 [2000-05-02 00:29 UTC] hrothgar at techie dot com
I tried that.  Made the change, then did `apachectrl restart`.  Still gave me the parse error.  Sounds like the short tags option isn't working.
 [2002-10-01 07:09 UTC] xanthor at netcourrier dot dot com
A solution is to write :

<?php
echo('<?xml version="1.0" encoding="UTF-8"?>');
?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"DTD/xhtml1-strict.dtd">
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Fri Sep 19 19:00:01 2025 UTC