How to determine the mobile phone system in php

WBOY
Release: 2016-07-30 13:31:15
Original
1472 people have browsed it
It is now very popular to scan QR codes to download apps. Do you know the principle?

The scanned QR code is essentially a link. This link will execute a method and jump to different App download platforms according to different mobile phone systems.

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

The above introduces how PHP determines the mobile phone system, including aspects of the system. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!