Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

XHTML to HTML

Name: Anonymous 2007-03-17 22:26 ID:mmTvIK73

I'm currently working on a load of PHP to make my website show as XHTML with an application/xhtml+xml content-type to non-shitty browsers (Firefox, Opera, Safari) and as HTML with a text/html content-type to shitty browsers (Internet Explorer).

At this point I'm mostly done, but I've got one more minor issue that I want fix.

The code in both versions of the page has trailing slashes in some tags as is correct for XHTML, but I want to change that in the HTML version so "<br />"  becomes "<br>".

This is a very minor thing, but I'm fairly certain it can be done in PHP and would to do so.

Name: Anonymous 2007-03-18 2:45 ID:g95BiQ5+

That didn't seem to work. The code as I have it right now goes as follows:

<?php
if (stristr($_SERVER["HTTP_ACCEPT"],"application/xhtml+xml") ||
    stristr($_SERVER["HTTP_USER_AGENT"],"W3C_Validator")     ||
    stristr($_SERVER["HTTP_USER_AGENT"],"W3C_CSS_Validator") ||
    stristr($_SERVER["HTTP_USER_AGENT"],"WDG_Validator")) {
    header("Content-type: application/xhtml+xml; charset=utf-8");
    echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\"\n    \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n");                    
}
else {
    header("Content-type: text/html; charset=utf-8");
    echo("<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\n    \"http://www.w3.org/TR/html4/strict.dtd\">\n<html lang=\"en\">\n");
    str_replace(" />", ">", $page);
}
?>

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List