With more requirement of responsive websites it a basic requirement to detect device and browser of user accessing website. Here is an opensource class in PHP to detect device as well OS/browser and other features including tablets.
Plugins of this class are also available for WordPress, Joomla, Magento.
Demo:
http://demo.mobiledetect.net
Download:
http://mobiledetect.net
If you don’t wish to go much into code and need a quick solution, an alternate can also be:
[code]
[/code]
Thanks to an unknown author for above quick fix. : )