Home >Backend Development >PHP Problem >How to use PHP to judge the mobile phone and jump to it
The implementation method of php judging the mobile phone and jumping: first create a PHP sample file; then encapsulate the code for judging the jump into a commonly used function "ismobile"; finally use the ismobile function directly to judge the jump Just turn.
Recommendation: "PHP Video Tutorial"
PHP webpage determines the mobile phone version and automatically jumps to the mobile phone page
//新增 如果是手机访问 则跳转到手机端页面 if(strpos($agent,"comFront") || strpos($agent,"iPhone") || strpos($agent,"MIDP-2.0") || strpos($agent,"Opera Mini") || strpos($agent,"UCWEB") || strpos($agent,"Android") || strpos($agent,"Windows CE") || strpos($agent,"SymbianOS")) header("Location:http://hd2017.cn/index.php?m=mobile&a=index");
We can encapsulate it into a commonly used function!
// $murl 为手机端的页面地址 function ismobile($murl=""){ //新增 如果是手机访问 则跳转到手机端页面 if(strpos($agent,"comFront") || strpos($agent,"iPhone") || strpos($agent,"MIDP-2.0") || strpos($agent,"Opera Mini") || strpos($agent,"UCWEB") || strpos($agent,"Android") || strpos($agent,"Windows CE") || strpos($agent,"SymbianOS")) header("Location:{$murl}"); }
This will be much more convenient when we use it!
The above is the detailed content of How to use PHP to judge the mobile phone and jump to it. For more information, please follow other related articles on the PHP Chinese website!