|
Function isMobile (){
If (isset ($ _ SERVER ['HTTP _ X_WAP_PROFILE ']) {
Return true;
}
If (isset ($ _ SERVER ['HTTP _ VIA ']) {
// Flase cannot be found; otherwise, true
Return stristr ($ _ SERVER ['HTTP _ vean'], "wap ")? True: false;
}
If (isset ($ _ SERVER ['HTTP _ USER_AGENT ']) {
// This array needs to be improved
$ 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'
);
// Search for the keyword of the mobile browser from HTTP_USER_AGENT
If (preg_match ("/(". implode ('|', $ clientkeywords ). ")/I", strtolower ($ _ SERVER ['HTTP _ USER_AGENT ']) {
Return true;
}
}
// Resolution, which may be inaccurate and placed in 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;
} |