php判断是不是手机端访问

最笨方法自己亲测!

if (isset($_SERVER[‘HTTP_USER_AGENT‘])) {
$clientkeywords = array(‘iphone‘, ‘android‘, ‘phone‘, ‘mobile‘, ‘wap‘, ‘netfront‘, ‘java‘, ‘opera mobi‘, ‘opera mini‘,‘ucweb‘, ‘windows ce‘, ‘symbian‘, ‘series‘, ‘webos‘, ‘sony‘, ‘blackberry‘, ‘dopod‘, ‘nokia‘, ‘samsung‘,‘palmsource‘, ‘xda‘, ‘pieplus‘, ‘meizu‘, ‘midp‘, ‘cldc‘, ‘motorola‘, ‘foma‘, ‘docomo‘, ‘up.browser‘,‘up.link‘, ‘blazer‘, ‘helio‘, ‘hosin‘, ‘huawei‘, ‘novarra‘, ‘coolpad‘, ‘webos‘, ‘techfaith‘, ‘palmsource‘,‘alcatel‘, ‘amoi‘, ‘ktouch‘, ‘nexian‘, ‘ericsson‘, ‘philips‘, ‘sagem‘, ‘wellcom‘, ‘bunjalloo‘, ‘maui‘, ‘smartphone‘,‘iemobile‘, ‘spice‘, ‘bird‘, ‘zte-‘, ‘longcos‘, ‘pantech‘, ‘gionee‘, ‘portalmmm‘, ‘jig browser‘, ‘hiptop‘,‘benq‘, ‘haier‘, ‘^lct‘, ‘320x320‘, ‘240x320‘, ‘176x220‘, ‘windows phone‘);
// 从HTTP_USER_AGENT中查找手机浏览器的关键字
if (preg_match("/(" . implode(‘|‘, $clientkeywords) . ")/i", strtolower($_SERVER[‘HTTP_USER_AGENT‘]))) {
echo 123;
}
}

php判断是不是手机端访问

上一篇:ios原生文字转语音


下一篇:App installation failed This application does not support this device’s CPU type.