# Going more mobile

I announced limited support for mobile devices viewing the blog recently. That support basically only covered phones with Opera Mini. Well now I have a WML theme installed so you should be able to view the site with any WAP device. You can force WML output with any browser though (although most browsers do not understand WML). Detecting Mobile Phones You’re first instinct is probably to check the user agent. Although it’s true there are fairly consistent ways to detect a phone from the user-agent there is a better way. One of the many under-utilised headers that browsers always send (well 99.99% of browsers you encounter will) is called Accept. This is just a list of MIME types that the browser can handle. Since all mobile phones (as well as PDAs can display WML pages, we’ll use this as the basis to detect mobile devices. The MIME type for WML pages always seemed rather odd to me: text/vnd.wap.wml. if (strpos($_SERVER['HTTP_ACCEPT'], 'text/vnd.wap.wml') !== false)$mobile = true; Now we need to find out if the phone can accept XHTML Basic (or XHTML Mobile Profile or whatever) in pretty much the same way: if (strpos($_SERVER['HTTP_ACCEPT'], 'application/xhtml+xml') !== false)$xhtml = true; Many “real” browsers are inconsistent with regards to the MIME type for XHTML. As far as I know since mobile phones do not have any sort of backwards compatibility issues they all use the proper application/xhtml+xml. cell phones