简体   繁体   English

如何在php中检测移动浏览器

[英]How to detect the mobile browsers in php

I tried this code this code to detect the browsers in mobile 我尝试使用此代码将此代码检测到移动设备中的浏览器

<?php
function isMobile() {
    return preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"]);
}
// If the user is on a mobile device, redirect them
if(isMobile())
{

  echo 'mobile';
}
else
{
    echo 'desktop';
}
?>

But it is not detecting the mobile browsers, can any one tell me how to fix this issue 但是它没有检测到移动浏览器,任何人都可以告诉我如何解决此问题

http://detectmobilebrowsers.com/也可以很好地工作-或Adam的建议也很好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM