Home  >  Article  >  Backend Development  >  How to determine the mobile phone system in php

How to determine the mobile phone system in php

WBOY
WBOYOriginal
2016-07-30 13:31:151519browse
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');
}

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.

Statement:
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