Total Pageviews

Sunday, June 23, 2013

Detect Browser in php, User agent detection in php

function detect_mobile()
{
    if(preg_match('/(alcatel|amoi|android|avantgo|blackberry|benq|cell|cricket|docomo|elaine|htc|iemobile|iphone|ipad|ipaq|ipod|j2me|java|midp|mini|mmp|mobi|motorola|nec-|nokia|palm|panasonic|philips|phone|playbook|sagem|sharp|sie-|silk|smartphone|sony|symbian|t-mobile|telus|up\.browser|up\.link|vodafone|wap|webos|wireless|xda|xoom|zte)/i', $_SERVER['HTTP_USER_AGENT']))
        return true;

    else
        return false;
}

$mobile = detect_mobile();
if($mobile === true)
{

header("location:mobiledevice/index.php");

}
else
{

echo '<h3>you are looking via system browser</h3>';

/*echo $_SERVER['HTTP_USER_AGENT'];*/

}





Follow kvn_krishna on Twitter

No comments:

Post a Comment