Detect Device using php code

Posted: May 24, 2012 in php
Tags: , , ,

Here we can detect the mobile devices using php code. actually the code is detecting the device usign user agent.

please click here to download mobile detect code .


1. Download mobile detect code from above link.

2.Include and instantiate the class

$detect = new Mobile_Detect();

3.Check for a specific platform:

    // code to run for the Apple iOS platform.
    // code to run for the Google Android platform.

Other case insensitive available methods are isIphone(), isIpad(), isBlackBerry(), isKindle(), isOpera(), etc. For the full list of available methods check the demo.php file or the wiki.

Alternatively, if you are only interested in checking to see if the user is using a mobile device, without caring for specific platform:

if ($detect->isMobile()) {
    // any mobile platform
    // any tablet

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s