Home > php教程 > php手册 > 实例详解php如何判断手机系统(附代码)

实例详解php如何判断手机系统(附代码)

WBOY
Release: 2018-10-27 14:49:19
forward
1163 people have browsed it

这篇文章结合实例主要介绍了php如何判断手机系统,有一定的参考价值,感兴趣的朋友可以看看,希望可以帮助到你!

现在很流行扫二维码来下载App,你知道其中的原理吗?

扫描的二维码本质是一个链接,这个链接会执行一个方法,根据不同的手机系统跳转到不同的App下载平台。

header("Content-type:text/html; charset=utf-8");
$user_agent = $_SERVER['HTTP_USER_AGENT'];//返回手机系统、型号信息
//var_dump($user_agent);
if(stristr($_SERVER['HTTP_USER_AGENT'],'Android')){//返回值中是否有Android这个关键字
   //echo'你的手机是:Android系统';
header('Location: http://xxx');
}else if(stristr($_SERVER['HTTP_USER_AGENT'],'iPhone')){
   //echo'你的手机是:IOS系统';
header('Location: https://xxx');
}else if(stristr($_SERVER['HTTP_USER_AGENT'],'WindowsPhone')){
   //echo '你使用的是WindowsPhone系统';
header('Location: http://xxx');
}else{
header('Location: http://xxx');
}
Copy after login

【相关教程推荐】

1. php编程从入门到精通全套视频教程 

2. php从入门到精通  

3. bootstrap教程 

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template