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 8 of 8
  1. #1
    Regular Coder
    Join Date
    Oct 2006
    Posts
    164
    Thanks
    5
    Thanked 0 Times in 0 Posts

    PHP file being served as application/xhtml+xml

    Hello, I have a php file and i want it to be served as application/xhtml+xml.

    Heres the file:
    PHP Code:
    <?php echo '<?xml version="1.0" encoding="UTF-8"?>'?>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>Eli Loewen Designs</title>
    <meta name="description" content="Eli Loewen Web Design" />
    <?php include('../keywords.php'); ?>
    <link href="../stylesheet.css" rel="stylesheet" type="text/css" />
    </head>
    <body>
    <div id="all">
        <div id="header"></div>
        <div id="menu_top"></div>
        <div id="menu">
            <div id="menu_left"></div>
            <div id="menu_divider_1"></div>
            <div id="home_active"><a href="../home/" title="Home"></a></div>
            <div id="menu_divider_2"></div>
            <div id="portfolio"><a href="../portfolio/" title="Portfolio"></a></div>
            <div id="menu_divider_3"></div>
            <div id="services"><a href="../services/" title="Services"></a></div>
            <div id="menu_divider_4"></div>
            <div id="blog"><a href="../blog/" title="Blog"></a></div>
            <div id="menu_divider_5"></div>
            <div id="contact"><a href="../contact/" title="Contact"></a></div>
            <div id="menu_divider_6"></div>
            <div id="links"><a href="../links/" title="Links"></a></div>
            <div id="menu_right"></div>
        </div>
        <div id="content">
            <div id="content_background">
                <div id="content_top"></div>
                <div id="content_middle">
                <h1>Welcome to Eli Loewen Designs </h1>
                <p>With over 5 years of web design experience, I have extensive  HTML, CSS, etc. knowledge. Every layout/design I make is completely XHTML 1.1  and CSS valid and always encoded with Unicode (UTF-8).</p>
                <p>So far, every layout I have made I have done free of cost.  My reasoning for this is that I believe that the best things in life are free. In  addition, most new, up and coming people who want to make a web site really  have no means of paying for stuff online because they are use usually under the  age of 18.</p>
                <p>Note: For this design and the rest of my works: From now on  I am going to stop trying to make my creations work in old browsers (That means  if you’re using IE6, this site is going to look bad). If this web site looks bad  and you have an outdated browser, then you should upgrade your browser to the latest version. That means if you have IE6 you should upgrade to IE7 or even better, Firefox 2. </p>
                <h2>Donate?</h2>
                <p>If you would like to donate to this site to help keep this up and running for as long as possible, please use the link below to go to the new donation page.</p>
                <p><a href="donation.php">Donation Page</a></p>
              </div>
                <div id="content_bottom"></div>
            </div>
        </div>
        <div id="footer">
    <?php include('../footer.php'); ?>
        </div>
    </div>
    <?php include('../codes.php'); ?>
    </body>
    </html>
    What do i change/add to get it to be served with that MIME type?

    Thank you.
    Not much, but its something.

  • #2
    Regular Coder croatiankid's Avatar
    Join Date
    Jan 2006
    Posts
    665
    Thanks
    1
    Thanked 12 Times in 12 Posts
    You need to change it on your server, so that the Content-Type HTTP header says it's the MIME type you want. I think you can use the PHP header() function/whatever it is, as well as htaccess, and you could easily search for it on the web.

  • #3
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Why did you post this in the html/css forum when this is clearly a php issue?
    Make a file called mimetype.php and put this in it
    PHP Code:
    <?php
    if(eregi(basename(__FILE__),$_SERVER['REQUEST_URI']))
    die(
    'You cannot access this file directly.');
    function 
    set_header()
    {

       
    $charset "utf-8";
       
    $mime "text/html";

       if(
    stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml")) {
           
    // if there's a Q value for "application/xhtml+xml" then also
           // retrieve the Q value for "text/html"
           
    if(preg_match("/application\/xhtml\+xml;q=0(\.[1-9]+)/i",
                                
    $_SERVER["HTTP_ACCEPT"], $matches)) {
                
    $xhtml_q $matches[1];
                if(
    preg_match("/text\/html;q=0(\.[1-9]+)/i",
                                     
    $_SERVER["HTTP_ACCEPT"], $matches)) {
                    
    $html_q $matches[1];
                    
    // if the Q value for XHTML is greater than or equal to that
                    // for HTML then use the "application/xhtml+xml" mimetype
                    
    if($xhtml_q >= $html_q) {
                         
    $mime "application/xhtml+xml";
                        }
                }
           
    // if there was no Q value, then just use the
           // "application/xhtml+xml" mimetype
           
    } else {
                
    $mime "application/xhtml+xml";
           }
       }
       
    // output the mime type and prolog type
       
    header("Content-Type: $mime;charset=$charset");
       
    header("Vary: Accept");
    }
    ?>
    then on the page you want to have the mimetype add this
    PHP Code:
    include_once('mimetype.php');
    set_header(); 
    The browsers that support that mimetype will get it. The browsers that don't support it will get text/html. I would also be careful with this line
    PHP Code:
    <?php echo '<?xml version="1.0" encoding="UTF-8"?>'?>
    as its putting IE6 into quirks mode causing some things not to render properly.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #4
    Regular Coder
    Join Date
    Oct 2006
    Posts
    164
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Ok ,i did that. The page is at http://www.eliloewen.com/home/new.php, but it is still being served as text/html? What am i doing wrong?

    Heres the head up.
    PHP Code:
    <?php include_once('mimetype.php');
    set_header(); ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
    <title>Eli Loewen Designs</title>
    <meta name="description" content="Eli Loewen Web Design" />
    <?php include('../keywords.php'); ?>
    <link href="../stylesheet.css" rel="stylesheet" type="text/css" />
    </head>
    Last edited by Sman5109; 07-10-2007 at 10:34 PM.
    Not much, but its something.

  • #5
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Make sure nothing comes before that code including spaces, and new line characters.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #6
    Regular Coder
    Join Date
    Oct 2006
    Posts
    164
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Yep, your right, it was a space in the file. But now for some reason the background of the page is messed up. What do i do to fix it?

    Also, in the (new) validator, why does it say its being served as text/html?
    http://validator-test.w3.org/check?u...home%2Fnew.php
    Not much, but its something.

  • #7
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    In true XML the background needs to be put on the html element not the body. Its best to put it on both. The validator is getting the text/html mimetype. Read this
    http://juicystudio.com/article/conte...iation.php#php
    You know its best to actually read what things tell you. You get to learn on your own.
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #8
    Regular Coder
    Join Date
    Oct 2006
    Posts
    164
    Thanks
    5
    Thanked 0 Times in 0 Posts
    Ok, thanks very much Your a great help.
    Not much, but its something.


  •  

    Posting Permissions

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