这是网上写的代码:
// 判断是否是手机
function is_mobile()
{
$agent = strtolower($_SERVER['HTTP_USER_AGENT']);
$mobileList = array('windows phone', 'mac os', 'iphone', 'android', 'ipad');
foreach($mobileList as $value) {
if(strpos($agent, $value) !== false) {
return true;
}
}
return false;
mac os为什么成为了移动端的标识?不是应该是苹果电脑吗?
你可以用Mobile_Detect库判断,git上有下载