Home > Article > Backend Development > How to determine the mobile phone system in php
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.