Click to See Complete Forum and Search --> : XML declaration and PHP...
Mr Initial Man
04-15-2005, 01:26 PM
I wasn't sure if I should have stuck this in the XML forum or the PHP forum, so I stuck it in both.
I used the following declaration in an XHTML document:
<?xml version="1.0" encoding="iso-8859-1"?>
What I got in return was the following:
Parse error: syntax error, unexpected T_STRING in C:\xampp\xampp\htdocs\!my_pages!\furry_site\Heads\main.htm on line 1
When I took the XML declaration out, my website worked.
Can I get the XML declaration to work with PHP, or am I out of luck?
You can just echo it out with PHP:
<?PHP
echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?>
...or, you could turn off short tags.
Edit: Oh, and I removed your thread in the XML forum.
amazing_andr3
04-15-2005, 02:42 PM
The PHP engine thinks that's PHP code and parses it, echoes an error and that causes a XML parsing error.
Place this in a .htaccess file in the root:
php_flag short_open_tag Off
You can also change other PHP directives with .htaccess , for instance
php_flag display_errors Off
php_flag magic_quotes_gpc Off
Edit: oh, and make sure you change any PHP short tags;
for example, <?=$var?> becomes <?php echo $var?>
Mr Initial Man
04-15-2005, 05:37 PM
To Pyro: No problem, just wasn't sure where to put the question.
Couple of questions, though
1) Would it be okay to simply do without the XML declaration? It's an XHTML 1.0 document.
2)If I stick <?PHP echo '<?xml version="1.0" encoding="iso-8859-1"?>';?> in the main.htm insert, and rename it to main.php, would that work?
Yes, I'm a lazy sack of [ CENSORED ]
EDIT: Never mind, I tried it myself. Holy smokes, it DOES work, and I didn't even need to change the file type. Fancy that...
Stephen Philbin
04-15-2005, 07:26 PM
That's basically what I do anyway. I just check for acceptance of XML and if it's there, then I serve as XML/XHTML and stick in the xml declaration. If it isn't, then I just serve as text/html and ommit the xml declaration.
Mr Initial Man
04-15-2005, 09:47 PM
Thing is, the reason for the XML declaration was so that IE would go into quirks mode, so my CSS would work. I'm redoing my site, and completely changing the CSS, so the XML declaration isn't really needed.
amazing_andr3
04-16-2005, 04:15 AM
Thing is, the reason for the XML declaration was so that IE would go into quirks mode, so my CSS would work. I'm redoing my site, and completely changing the CSS, so the XML declaration isn't really needed.Now why on earth are you doing that? The XML declaration is the proper way to declare a XHTML document, plus IE in quirks mode is a good thing.
Mr Initial Man
04-16-2005, 11:23 PM
*Shrugs.* No real reason, I guess. I didn't know if it would make a difference or not.