| | |
Php parser error when xml version is mentioned
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jul 2004
Posts: 2
Reputation:
Solved Threads: 0
Hi Guys,
When I am using XML version in the XHTML, then I am getting parser error [Parse error: parse error, unexpected T_STRING on line 1].
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Testing Page</title>
</head>
<body>
<p>Hi</p>
</body>
</html>
When I store the above code under .php extension, I am getting parser error.
Observations:
- When I stored the same code under .htm extension, I am not getting any error.
- When I remove the version and encoding and just use <?xml?> in the first line and use .php extension, I am not getting any error.
System:
Apache/2.0.50 (Win32)
PHP Version 4.3.8 [Build Date Jul 13 2004 17:31:56]
Can you please help in understand what is going on and why parser error. I like to use the version in XML just to conform with w3c.org XHTML standards.
When I am using XML version in the XHTML, then I am getting parser error [Parse error: parse error, unexpected T_STRING on line 1].
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-US" lang="en-US">
<head>
<title>Testing Page</title>
</head>
<body>
<p>Hi</p>
</body>
</html>
When I store the above code under .php extension, I am getting parser error.
Observations:
- When I stored the same code under .htm extension, I am not getting any error.
- When I remove the version and encoding and just use <?xml?> in the first line and use .php extension, I am not getting any error.
System:
Apache/2.0.50 (Win32)
PHP Version 4.3.8 [Build Date Jul 13 2004 17:31:56]
Can you please help in understand what is going on and why parser error. I like to use the version in XML just to conform with w3c.org XHTML standards.
•
•
Join Date: Jul 2004
Posts: 2
Reputation:
Solved Threads: 0
I am giving this answer for future reference for somebody looking for the same answer.
The syntax is correct, but the following pages gave me the information I need:
http://www.php.net/manual/en/language.basic-syntax.php
http://www.php.net/manual/en/ini.sec...short-open-tag
The answer is:
[1] Either disable short_open_tag in the php.ini. [But not always we have the option as webhosting company might not be willing to change.]
[2] The alternative is to use this
The syntax is correct, but the following pages gave me the information I need:
http://www.php.net/manual/en/language.basic-syntax.php
http://www.php.net/manual/en/ini.sec...short-open-tag
The answer is:
[1] Either disable short_open_tag in the php.ini. [But not always we have the option as webhosting company might not be willing to change.]
[2] The alternative is to use this
•
•
•
•
<?php echo("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); ?>
![]() |
Similar Threads
- PHP Parse error: syntax error, unexpected T_VARIABLE (PHP)
- Error in Getting XML (XML, XSLT and XPATH)
- PHP parsing error, unexpected '<' (PHP)
- xml parser to validate xml files-Urgent (XML, XSLT and XPATH)
- PHP Parse error: parse error, unexpected T_STRING (PHP)
Other Threads in the PHP Forum
- Previous Thread: webcam and voice recording
- Next Thread: php 5
| Thread Tools | Search this Thread |
# address apache api array autoincrement beginner binary broken cakephp checkbox class clean cms code countingeverycharactersfromastring crack cron curl database date decode dehasher directory display dissertation dynamic echo email error fairness file files folder form forms function functions google href htaccess html image include incode insert ip javascript joomla legislation limit link login mail masterthesis match menu method mlm multiple mysql newsletters oop pagerank paypal pdf persist php play protocol query question radio random remote root script search server sessions simple sms soap source space spam sql support! syntax system table tutorial update upload url validator variable video web youtube





