Detect Mobile Browsers Help and Examples

Need further help?

If you need further help please upgrade by paying the $20 upgrade fee:

PayPal

http://detectmobilebrowsers.mobi/

PHP in HTML:

The most common issue is getting this PHP function to work on HTML pages, to combat this we have a seperate page to help you: html.html

Usage examples:

Detect and redirect all mobile requests to google.mobi:

An example of this is presented in this page, if you've got PHP working in HTML just hit this page with a mobile user agent to redirect to google.mobi

    <?php
    include('mobile_device_detect.php');
    mobile_device_detect(true,true,true,true,true,true,'http://google.mobi/',false);
    ?>

Detect and redirect all non-mobile requests to google.com:

    <?php
    include('mobile_device_detect.php');
    mobile_device_detect(true,true,true,true,true,true,false,'http://google.com/');
    ?>

Detect and redirect: Mobiles to google.mobi and non-mobiles to google.com

    <?php
    include('mobile_device_detect.php');
    mobile_device_detect(true,true,true,true,true,true,'http://google.mobi/','http://google.com/');
    ?>

Include one file for mobiles and one file for non-mobiles::

    <?php
    include('mobile_device_detect.php');
    if(mobile_device_detect(true,true,true,true,true,true,false,false)){
      include('mobile.html');
    }else{
      include('non-mobile.html');
    }
    ?>

How to test without a mobile phone

You can test this works by using FireFox with the User Agent Switcher plugin

That plugin will let you override your brower's default user agent with ones you set yourself. Here's some sample user agent strings to get you started:

Nokia N95:Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaN95/11.0.026; Profile MIDP-2.0 Configuration/CLDC-1.1) AppleWebKit/413 (KHTML, like Gecko) Safari/413
iPhone 2g:Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3
iPhone 3g:Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5F136 Safari/525.20
Nokia 7250i:Nokia7250I/1.0 (3.22) Profile/MIDP-1.0 Configuration/CLDC-1.0
Google G1:Mozilla/5.0 (Linux; U; Android 1.0; en-gb; dream) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2
Opera Mini:Opera/9.50 (J2ME/MIDP; Opera Mini/4.1.10781/298; U; en)

Download a sample xml file for User Agent Switcher with several mobile user agents here

Need further help?

If you need further help please upgrade by paying the $20 upgrade fee:

PayPal

http://detectmobilebrowsers.mobi/