webman中,有没有哪位大佬有写好的判断请求终端是否为手机端的代码,麻烦分享下哈,感谢!
问AI
谢谢!
https://github.com/jenssegers/agent
感谢!参考下哈
function is_mobile(){ $userAgent = request()->header('user-agent'); $mobileAgents = ["Android", "iPhone", "iPod", "iPad", "Windows Phone", "BlackBerry", "SymbianOS"]; foreach ($mobileAgents as $mobileAgent) { if (strpos($userAgent, $mobileAgent) !== false) { return true; } } return false; }
谢谢了哈!
感谢大佬们回复,这么简单折腾一下用着:
function is_mobile(){ $userAgent = request()->header('user-agent'); if(preg_match('/(iphone|ipod|ipad|android|blackberry|webos|windows phone|mobile)/i', $userAgent)) { return true; } return false; }
问AI
谢谢!
https://github.com/jenssegers/agent
感谢!参考下哈
谢谢了哈!
感谢大佬们回复,这么简单折腾一下用着: