Collin Davis wrote:
PHP can go hand in hand with Content Negotiation!
Check out this link: http://keystonewebsites.com/articles/mime_type.php
Read through the article - it explains how it works very well. Since XHTML
is merely a reformulation of HTML, you can use the HTTP_ACCEPT header to
serve XHTML as application/xhtml+xml to browser that recognize it, and HTML
as text/html to those that can't properly recognize XHTML. Also of note, is
that the script properly replaces /> with > when serving HTML.
My own feeling is that since "text/html" is also a valid content type
for XHTML, if "application/xhtml+xml" isn't accepted, I just send it as
is with "text/html". For the most part, only IE is the issue since every
other browser of note accepts "application/xhtml+xml", and since IE is
so used to eating garbage that it couldn't tell the difference between
gourmet food and spam, why bother?
On a related note, since the W3C's validator doesn't send an
"HTTP_ACCEPT" header, you should also look at the "HTTP_USER_AGENT"
header as well. While I normally would advise against browser sniffing,
I make exceptions for the W3C Validator, the W3C CSS Validator, and the
WDG Validator.
******************************************************
The discussion list for http://webstandardsgroup.org/
See http://webstandardsgroup.org/mail/guidelines.cfm
for some hints on posting to the list & getting help
******************************************************