Forum Moderators: coopster

Message Too Old, No Replies

XHTML validation issue

the PHP parser doesn't like it.

         

mcvoid

4:49 am on May 11, 2006 (gmt 0)

10+ Year Member



I have a php page with 1 line of php code (<?php include 'news.htm';?> to be exact), but it comes up with a parsing error on line 1, which is:
<?xml version="1.0" encoding="UTF-8"?>
I see why the parser doesn't like it, but when I remove that line, the page won't validate. It will show an error on the style tag. I tried switching to asp-style tags to no avail. Putting it script tags causes the parser to overlook it and not include the page.
Can anybody think of a workaround?

siMKin

6:55 am on May 11, 2006 (gmt 0)

10+ Year Member



that's because short-tags are enabled in your php-configuration. so, the parser thinks that with <? you are actually saying <?php.
1 solution is to disable short tags. another is to do this:
<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";?>

mcvoid

3:05 pm on May 12, 2006 (gmt 0)

10+ Year Member



I ended up doing the echo thing and it works, though the fact that I have to do that irks me. I don't like the idea of not being able to read it right from an XML user agent when it's not coming through http.

It's a patch for now, but I guess I'll need to fight with my hosting service to take off short tags in php.ini.
It's times like this when I wish it was on my own machine. :)

coopster

3:18 pm on May 12, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



short_open_tag [php.net] is of type
PHP_INI_PERDIR
so you could override it in your site root with a per-directory override file (.htaccess) if they will allow that. Some hosts won't allow any PHP directives in per-directory override files though.