Php code used to determine whether the access source is a mobile phone and jump automatically
This article introduces php to check whether the access source is a mobile phone. If yes, it will automatically jump to the two methods on the mobile phone page. For more information, see. The following two methods can be used to determine whether the visitor's terminal source is a mobile phone or a common webpage, and then redirect. Method 1:
Method 2:
0){$is_wap = 1;} elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP") > 0 || strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"UC/") > 0){ $is_wap = 1;} else { $iUSER_AGENT=strtoupper(trim($_SERVER['HTTP_USER_AGENT'])); if(strpos($iUSER_AGENT,"NOKIA")>0 || strpos($iUSER_AGENT,"WAP")>0 || strpos($iUSER_AGENT,"MIDP")>0 || strpos($iUSER_AGENT,"UCWEB")>0 )$is_wap == 1; } if($is_wap==1){header('Location:wap/index.php');exit;}?> If you are interested, try either of the two methods to see which one can obtain the visitor's source accurately. |