Now when mobile devices are really popular, and when more and more mobile visitors are visiting our websites, it is really common task to recognize mobile device in order to execute additional snippet of programming code, or some other specialized action. Here I want to share with you how to do it using PHP.

I would like to suggest you Mobile Detect PHP library. It is really lightweight PHP library containing only one file which can be included in your project by just putting require_once command. I don’t want to include in my project some huge library consisting of dozens of files with unnecessary functions. Also, there are some 3rd party plugins  available for Wordpress, Drupal, Joomla, Magento, etc. so if you are running one of these, it is quite useful.

Here is snippet of code how to use a library.

The library is pretty effective. I have tested it with several devices including: Nexus 4, Nexus 5, iPhone 4, iPhone 5, iPhone 6, Samsung Galaxy 2,3,4,5,6, Asus tablets, iPad, iPad mini.

If you want to test it with your device, here is test link.

How to detect mobile device using PHPhttp://code-epicenter.com/wp-content/uploads/2015/09/devices.pnghttp://code-epicenter.com/wp-content/uploads/2015/09/devices-150x150.pngAmir DuranPHPProgramminglibrary,Mobile Device,PHP
Now when mobile devices are really popular, and when more and more mobile visitors are visiting our websites, it is really common task to recognize mobile device in order to execute additional snippet of programming code, or some other specialized action. Here I want to share with you how to do...