PHP
·
发表于 5年以前
·
阅读量:8298
function is_mobile()
{
if (isset ($_SERVER['HTTP_USER_AGENT'])) {
$clientkeywords = array ('nokia', 'sony','ericsson','mot',
'samsung','htc','sgh','lg','sharp',
'sie-','philips','panasonic','alcatel',
'lenovo','iphone','ipod','blackberry',
'meizu','android','netfront','symbian',
'ucweb','windowsce','palm','operamini',
'operamobi','openwave','nexusone','cldc',
'midp','wap','mobile'
);
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode('|', $clientkeywords) . ")/i", strtolower($_SERVER['HTTP_USER_AGENT']))){
return true;
} else {
return false;
}
} else {
return false;
}
}