Home >Backend Development >PHP Tutorial >PHP code to determine whether mobile phone access

PHP code to determine whether mobile phone access

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 09:00:21792browse
PHP detects whether the client user has mobile access. The code is very simple. Friends in need can refer to it.

The code is as follows:

<?php  
    //php判断客户端是否为手机  
    $agent = $_SERVER['HTTP_USER_AGENT'];  
    if(strpos($agent,"NetFront") || 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:xxxxxxxx");  
?>

You can also refer to:php js code to determine whether mobile phone access



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