How can I determine whether a browser is a mobile phone browser or a computer browser? do I want to display different pages based on different devices to determine the IP address ??? What are the IP segments of the two ~~~ Or determine the browser type ??? This seems to have too many browsers ~~~ ------ Solution -------------------- there is no absolute way to separate. The following functions are provided. if they are not intentionally obfuscated, the success rate is above 99% ~ Function & nbsp; isMobile () & nbsp
To display different pages based on different devices
Are IP addresses determined ??? What are the IP segments of the two ~~~
Or determine the browser type ??? This seems to have too many browsers ~~~
------ Solution --------------------
There are no absolute methods to separate.
The following functions are provided. if they are not intentionally obfuscated, the success rate is above 99% ~
Function isMobile (){
If (isset ($ _ SERVER ['http _ X_WAP_PROFILE ']) {
Return TRUE;
}
If (isset ($ _ SERVER ['http _ vean']) & stristr ($ _ SERVER ['http _ vean'], "wap ")){
Return TRUE;
}
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 ');
If (preg_match ("/(". implode ('
------ Solution --------------------
', $ Clientkeywords). ")/I", strtolower ($ _ SERVER ['http _ USER_AGENT']) {
Return TRUE;
}
}
If (isset ($ _ SERVER ['http _ ACCEPT ']) {
If (strpos ($ _ SERVER ['http _ ACCEPT '], 'vnd. wap. wml ')! = False)
& (Strpos ($ _ SERVER ['http _ ACCEPT '], 'text/html') = false
------ Solution --------------------
(Strpos ($ _ SERVER ['http _ ACCEPT '], 'vnd. wap. wml') <strpos ($ _ SERVER ['http _ ACCEPT '], 'text/html ')))){
Return TRUE;
}
}
Return FALSE;
}