Wednesday, September 10, 2008

Detecting mobile devices using PHP

The developers will be happy to find this info which I bumped into today. Hand Interactive has published an article on how to detect a mobile device using PHP.

“Don’t you wish there were an easy way to detect whether your web site visitor is connecting with a desktop PC or a mobile device of some sort?
The good news is that using PHP (or another server-based scripting language), it’s sort of easy to detect some devices by parsing the UserAgent string. Because the code is run on the server rather than in the browser itself (such as JavaScript), these PHP-based techniques yield better reliability in detecting mobile devices. Just remember that there are lots of important caveats, including:
  • These technqniques depend on the contents of the UserAgent string. As a result, these techniques may not work if the browser is emulating a different one (e.g., some mobile browsers can be set to emulate Internet Explorer).
  • Mobile operators can also change the UserAgent contents when the device is customized for their networks and added to their stock device portfolio. Operators also sometimes change the UserAgent value as the page request passes through their networks.
  • UserAgent strings are moving targets. Once implemented, you’ll need to monitor the effectiveness of your code against the list of your high priority devices or platforms. “
Read the full article at Hand Interactive and download the PHP codeSource & Link : Hand Interactive



Twitter Delicious Facebook Digg Stumbleupon Favorites More