PHP 判断当前访问设备是电脑还是手机
2020年07月28日
| 萬仟网IT编程
| 我要评论
function is_mobile(){ $regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|"; $regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|"; $regex_match.
function is_mobile(){
$regex_match="/(nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\.browser|up\.link|";
$regex_match.="htc|dopod|blazer|netfront|helio|hosin|huawei|novarra|CoolPad|webos|techfaith|palmsource|";
$regex_match.="blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson|philips|sagem|wellcom|bunjalloo|maui|";
$regex_match.="symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-|longcos|pantech|gionee|^sie\-|portalmmm|";
$regex_match.="jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320|240x320|176x220";
$regex_match.=")/i";
$state=preg_match($regex_match, strtolower($_SERVER['HTTP_USER_AGENT']));
//pc返回0,手机返回1
return $state;
}
本文地址:https://blog.csdn.net/qq_39521804/article/details/107581089
如您对本文有疑问或者有任何想说的,请点击进行留言回复,万千网友为您解惑!
相关文章:
本文实例讲述了php时间类。分享给大家供大家参考,具体如下:
header("content-...
本文实例讲述了php开发的微信现金红包功能。分享给大家供大家参考,具体如下:
微信商家后台-现金红包开发
sdk
&l...
函数string rd_kafka_err2str ( integer $err ) 将rdkafka错误代码转换为字符串 integer rd_k...
php fclose()函数 语法
作用:关闭一个打开文件
语法:
fclose(file)
参数:
file...
很多人首先会想从服务器缓存方面着手对程序进行优化,许多不同的服务器缓存方式都有他们自己的特点,像我曾经参与的一些项目中,根据缓存的命...
本文实例讲述了php设计模式之简单工厂和工厂模式。分享给大家供大家参考,具体如下:
工厂模式是创建型模式的一种,分为简单工厂模式,...
本文实例讲述了php简单获取及判断提交来源的方法。分享给大家供大家参考,具体如下:
echo $_server['http...
没有什么好说的了,直接上代码吧:
/**
* 太平洋时间转北京时间
*/
public functi...
本文实例讲述了php面向对象程序设计重载(overloading)操作。分享给大家供大家参考,具体如下:
重载
php中的”重载...
本文实例讲述了php实现生成pdf文件的方法。分享给大家供大家参考,具体如下:
首先要下载fpdf
或者点击此处。
例子:将...
网友评论
验证码: