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 11 of 11
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Location
    USA
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question XHTML has a problem with include scripts?

    I plan to update my HTML 4.0.1 scripts to XHTML.

    Currently I have been using .php scripts for the header and footer which is something like:

    <html>
    <body>

    <?php include("header.php"); ?>

    <table>
    Text.
    </table>

    <?php include("header.php"); ?>

    </body>
    <html>

    But my .php script doesn't show when I convert my script to XHTML which has the doctype as follows:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">


    Does XHTML have a problem with php includes?

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    are you're files saved as PHP files?

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Location
    USA
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts
    yes, the file has a .php extension.

    otherwise, my server won't treat them as .php scripts.

    why? Can I not do that?

  • #4
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i'm talking about the main file, not the includes. but, yes, you have to give it an extension of .php.

    of course, you have to have PHP installed on the server. you sure you've got that set up. sounds to me like you don't.

  • #5
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    wot's in the include files?

  • #6
    Regular Coder
    Join Date
    Oct 2002
    Location
    USA
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I think I was not clear.

    I am ALREADY using PHP. No problems with my server.

    What I am trying to do is to update the HTML script to XHTML.

    The main file you mention (that has the includes in it) has a .php extention too.

    but the script is like I have written above.

  • #7
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    not sure, mate.

    seems to me that the HTML being parsed by your PHP includes could be at fault.

    if the incs work fine under plain-old HTML, then everything PHP-Apache side is fine, so it must be the actual HTML itself within the incs.

    can we see wot the rendered HTML should be like?

  • #8
    Regular Coder
    Join Date
    Oct 2002
    Location
    USA
    Posts
    255
    Thanks
    1
    Thanked 0 Times in 0 Posts
    I now understood where the problem is, but I am not sure why it happens.

    Dreamweaver automatically inserts <?xml version="1.0" encoding="iso-8859-1"?> at the very beginning of the script.

    however, php includes do not work with it.

    there are no problems when I take it off.

    do you know why this happens?

  • #9
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hmmm, not really otherthan to suggest that it's prolly interfering with your DTD declaration.

    i'm not a fan of Dreamweaver. prefer to handcode everything. although wouldn't mind using M7 for JSP editing.

    if you're looking for an alternative tool to Dreamweaver for PHP editing, try using Eclipse. You'll need to get a PHP plugin for it, but it's a superb wee IDE, albeit not WYSIWIG.

  • #10
    Senior Coder Mhtml's Avatar
    Join Date
    Jun 2002
    Location
    Sydney, Australia
    Posts
    3,531
    Thanks
    0
    Thanked 1 Time in 1 Post
    This is a PHP question and should be in the PHP forum.

    Change it to this --
    PHP Code:
    <?php echo "<"."?xml version=\"1.0\" encoding=\"iso-8859-1\"?".">"?>
    Last edited by Mhtml; 05-05-2004 at 01:08 PM.
    Omnis mico antequam dominus Spookster!

  • #11
    Senior Coder
    Join Date
    Jun 2002
    Location
    near Oswestry
    Posts
    4,508
    Thanks
    0
    Thanked 0 Times in 0 Posts
    What's happening is that the XML processing instruction "<?" is being interpreted as a PHP instruction.

    What Mhtml posted will work if it's the only way, but the best solution if you can reconfigure PHP is to turn off short open tags, so that you have to go "<?php", and then the XML prolog won't trigger PHP parsing.
    "Why bother with accessibility? ... Because deep down you know that the web is attractive to people who aren't exactly like you." - Joe Clark


  •  

    Posting Permissions

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