On 26/07/2004, at 7:29 AM, Scrumpy wrote:
[EMAIL PROTECTED] (Suresh Manoharan) wrote in news:[EMAIL PROTECTED]:
[snip]I am getting parse error [Parse error: parse error, unexpected T_STRING on line 1] when I use XML version info.
<?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>Can you pls. help me understand why parsing error occurs and how to avoid it.
I just start with "<!DOCTYPE..." on the first line and exclude the "<?xml..." line completely and both parsing and validation are fine.
That's a workaround, not a solution.
The problem is that <?... is a PHP short tag, so the PHP engine thinks <?xml version="1.0" encoding="utf-8"?> is PHP code, which it isn't, hence the errors spit out by the PHP engine.
Solution 1:
Turn off short tags in your php.ini file, so that only <?php ... ?> will turn on the PHP engine. This may require a large rewrite of existing scripts though.
Solution 2: Instead of <?xml version="1.0" encoding="utf-8"?> on line 1, use <? echo '<?xml version="1.0" encoding="utf-8"?>'; ?>
In other words, let PHP's engine echo the XML declaration, avoiding the PHP parsing errors.
Regards
--- Justin French http://indent.com.au
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php