Detecting mobile devices
With mobile web being is all the rage these days, detecting mobile devices could be important.
WAP2 standard sets XHTML MP (Mobile Profile) as a markup language, and, more importantly for the purpose of this article, defines that the client agent should have an Accept header with the "application/vnd.wap.xhtml+xml" value. We will be using that requirement to identify a presumably mobile device accessing our script:
<?php
// ...
if ( strpos($_SERVER['HTTP_ACCEPT'],'application/vnd.wap.xhtml+xml')!==false )
{
// It's a mobile device, do something appropriate
}
// ..
?>




XHTML MP
You can get the Open Mobile Alliance document describing the XHTML MP 1.1 version here (pdf).
Content types
The same document describes that XHTML MP pages should be served with the "application/vnd.wap.xhtml+xml" or "application/xhtml+xml" content types. In practice, however, "text/html" seems to serve better. In fact when I use the "application/vnd.wap.xhtml+xml", my SonyEricsson K510i refuses to show me the content of the page.