Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post

    Problems when using the xml declaration in a php file

    I tried to make my php file XHTML 1.0 Strict compatible. Doing that means I had to add this at the top of the file:

    Code:
    <?xml version="1.0" encoding="ISO-8859-1"?>
    <!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" lang="en">
    It doesn't like how the xml declaration uses the "?" that php is accustomed to. I got away with an HTML 4.0 Strict DTD, but is there an alternative to doing this for XHTML compliance?

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You don't actually need the <?xml prologue to be compliant; it's optional. But if you want it there are two things you can do:

    You can modify your PHP config so that it requires "<?php" rather than just "<?" - I don't know the specifics of doing that though, and it may be a moot point if you can't change your server config (unless it can be done by setting a php.ini directive from .htaccess?)

    Or you can write out the prologue in PHP:
    PHP Code:
    <?php echo("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"); ?>
    Last edited by brothercake; 01-07-2004 at 05:42 AM.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark

  • #3
    Regular Coder
    Join Date
    Nov 2002
    Posts
    672
    Thanks
    1
    Thanked 1 Time in 1 Post
    Thanks. I didn't know it was optional. I did know there was an alternative way of adding the character encoding but this solution would be the best out of all of them.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •