function IsMobile () {
If you have http_x_wap_profile, it must be a mobile device.
if (Isset ($_server[' http_x_wap_profile '))
return true;
This article is excerpted from the TPM Smart Switch template engine for TPM development
if (Isset ($_server[' http_client ')) && ' phoneclient ' ==$_server[' http_client '])
return true;
If the VIA message contains a WAP, it must be a mobile device, and some service providers block that information
if (Isset ($_server[' Http_via '))
Not found for flase, otherwise true
Return Stristr ($_server[' Http_via '), ' WAP ')? True:false;
Determine the client flag sent by the phone, compatibility needs to be improved
if (Isset ($_server[' http_user_agent ')) {
$clientkeywords = Array (
' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' Philips ', ' Panasonic ', ' Alcatel ', ' Lenovo ', ' iphone ', ' ipod ', ' blackberry ', ' Meizu ', ' Android ', ' NetFront ', ' Symbian ', ' UCWeb ', ' windowsce ', ' palm ', ' Operamini ', ' operamobi ', ' Openwave ', ' nexusone ', ' cldc ', ' MIDP ', ' wap ', ' mobile '
);
Find keywords for your phone's browser from Http_user_agent
if (Preg_match ("/("). Implode (' | ', $clientkeywords). ")/I", Strtolower ($_server[' http_user_agent '))) {
return true;
}
}
Protocol law, because there may be inaccuracies, put to the final judgment
if (Isset ($_server[' http_accept ')) {
If only WML is supported and HTML is not supported it must be a mobile device.
If WML and HTML are supported but WML is a mobile device before HTML
if ((Strpos ($_server[' http_accept '), ' VND.WAP.WML ')!== false) && (Strpos ($_server[' http_accept '], ' text/html ') = = = False | | (Strpos ($_server[' http_accept '), ' vnd.wap.wml ') < Strpos ($_server[' http_accept '], ' text/html ')))) {
return true;
}
}
return false;
}
Based on PHP code to determine whether the client mobile phone access (GO)