Sometimes it's practical. On some occasions, keep the spare.
Copy CodeThe code is as follows:
function Is_mobile_request ()
{
$_server[' all_http ' = isset ($_server[' all_http '])? $_server[' all_http ': ';
$mobile _browser = ' 0 ';
if (Preg_match ('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/I ', Strtolower ($_server[' http_user_agent ')))
$mobile _browser++;
if ((Isset ($_server[' http_accept ')) and (Strpos (Strtolower ($_server[' http_accept ')), ' application/vnd.wap.xhtml+ XML ')!== false))
$mobile _browser++;
if (Isset ($_server[' http_x_wap_profile '))
$mobile _browser++;
if (Isset ($_server[' http_profile '))
$mobile _browser++;
$mobile _ua = Strtolower (substr ($_server[' http_user_agent '],0,4));
$mobile _agents = Array (
' The ' acs-', ' Alav ', ' Alca ', ' amoi ', ' Audi ', ' Avan ', ' BenQ ', ' bird ', ' Blac ',
' Blaz ', ' brew ', ' cell ', ' cldc ', ' cmd-', ' Dang ', ' doco ', ' Eric ', ' Hipt ', ' Inno ',
' iPAQ ', ' Java ', ' Jigs ', ' kddi ', ' Keji ', ' Leno ', ' lg-c ', ' lg-d ', ' lg-g ', ' lge-',
' Maui ', ' Maxo ', ' MIDP ', ' mits ', ' mmef ', ' mobi ', ' mot-', ' moto ', ' mwbp ', ' nec-',
' Newt ', ' Noki ', ' oper ', ' palm ', ' pana ', ' Pant ', ' Phil ', ' play ', ' Port ', ' ProX ',
' Qwap ', ' sage ', ' Sams ', ' Sany ', ' sch-', ' sec-', ' send ', ' Seri ', ' sgh-', ' Shar ',
' sie-', ' Siem ', ' smal ', ' Smar ', ' Sony ', ' sph-', ' symb ', ' t-mo ', ' Teli ', ' tim-',
' Tosh ', ' tsm-', ' upg1 ', ' upsi ', ' vk-v ', ' Voda ', ' wap-', ' wapa ', ' wapi ', ' Wapp ',
' Wapr ', ' webc ', ' winw ', ' winw ', ' xda ', ' xda-'
);
if (In_array ($mobile _ua, $mobile _agents))
$mobile _browser++;
if (Strpos (Strtolower ($_server[' all_http '), ' Operamini ')!== false)
$mobile _browser++;
pre-final Check to reset everything if the user are on Windows
if (Strpos (Strtolower ($_server[' http_user_agent '), ' windows ')!== false)
$mobile _browser=0;
But WP7 was also Windows, with a slightly different characteristic
if (Strpos (Strtolower ($_server[' http_user_agent '), ' windows Phone ')!== false)
$mobile _browser++;
if ($mobile _browser>0)
return true;
Else
return false;
}
Article Source: http://yi1.com.cn/posts/781
PHP determines user browser type based on Http_user_agent
Copy the Code code as follows:
function browsers () {
Global $HTTP _user_agent;
if (Isset ($HTTP _user_agent)) {
$sAgent = $HTTP _user_agent;
}else{
$sAgent = $_server[' http_user_agent ');
}
if (Strpos ($sAgent, ' MSIE ')!== false && Strpos ($sAgent, ' mac ') = = = False && Strpos ($sAgent, ' Opera ') = = = FA LSE) {
$iVersion = (float) substr ($sAgent, Strpos ($sAgent, ' MSIE ') + 5,3);
Return ($iVersion >= 5.5);
}else if (Strpos ($sAgent, ' gecko/')!== false) {
$iVersion = (int) substr ($sAgent, Strpos ($sAgent, ' gecko/') + 6,8);
Return ($iVersion >= 20030210);
}else{
return false;
}
}
http://www.bkjia.com/PHPjc/326626.html www.bkjia.com true http://www.bkjia.com/PHPjc/326626.html techarticle sometimes it's practical. On some occasions, keep the backup copy code code is as follows: function Is_mobile_request () {$_server[' all_http '] = isset ($_server[' all_http ')? $_ server[' All_htt ...