您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

PHP判断手机是IOS还是Android的三个方法

2024/3/6 15:03:07发布18次查看
本篇文章主要介绍php判断手机是ios还是android的三个方法,感兴趣的朋友参考下,希望对大家有所帮助。
实例1:主要是要用到http_user_agent,它表示的意思是用来检查浏览页面的访问者在用什么操作系统(包括版本号)浏览器(包括版本号)和用户个人偏好的代码。
监测代码如下:
function get_device_type(){ //全部变成小写字母 $agent = strtolower($_server['http_user_agent']); $type = 'other'; //分别进行判断 if(strpos($agent, 'iphone') || strpos($agent, 'ipad')){ $type = 'ios'; } if(strpos($agent, 'android')){ $type = 'android'; } return $type;}
通过调用objective-c这个函数,就能获取到手机的类型。
实例2:只需要一个判断就好
<?phpif(strpos($_server['http_user_agent'], 'iphone')||strpos($_server['http_user_agent'], 'ipad')){ echo 'systerm is ios';}else if(strpos($_server['http_user_agent'], 'android')){ echo 'systerm is android';}else{ echo 'systerm is other';}?>
实例3:这个实例可能有些偏题不过也分享给大家
function get_device_type(){ //全部变成小写字母 $agent = strtolower($_server['http_user_agent']); $type ='other'; //分别进行判断 if(strpos($agent,'iphone') || strpos($agent,'ipad')){ $type ='ios'; } if(strpos($agent,'android')){ $type ='android'; } return$type;}
总结:以上就是本篇文的全部内容,希望能对大家的学习有所帮助。
相关推荐:
php微信自动获取收货地址api用法实例详解
php判断用户是否已经登录实例分析
php实现微信公众号自定义分享内容的方法
以上就是php判断手机是ios还是android的三个方法的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product