Detect Mobile Browsers PHP in HTML Support Page

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,'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,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,'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,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)