This article mainly for you in detail the PHP judge is the mobile phone or PC side, and PHP to determine whether it is a browser, with a certain reference value, interested in small partners can refer to
The example of this article for everyone to share the PHP judgment of two instances, one is the PHP judgment is the mobile phone or PC side, and the second is PHP to determine whether the browser, for everyone to reference, the specific content as follows
1, to determine whether the mobile phone side
function IsMobile () {///If there is http_x_wap_profile, it must be a mobile device if (Isset ($_server[' http_x_wap_profile ')) {return true; }//If the VIA information contains WAP it must be a mobile device, some service associations block the information if (Isset ($_server[' Http_via ')) {//Cannot find for flase, otherwise true return Stristr ($_s erver[' Http_via '], "WAP")? True:false; }//Brain residue method, determine the mobile phone to send the client logo, compatibility needs to be improved. Where ' Micromessenger ' is the computer 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 ', ' Micromessenger '); Look for the keyword if (Preg_match ("/(") of the phone's browser from Http_user_agent. Implode (' | ', $clientkeywords). ")/I", Strtolower ($_server[' http_user_agent '))) {return true; }}//protocol method, because it may not be accurate, put to the Last Judgment if (Isset ($_server[' http_accept ')) {//If only WML is supported and HTML is not supported that must be mobile//if WML and HTML are supportedBut WML before HTML is the mobile device 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;}
2. Determine if it is a built-in browser
function Isweixin () { if (Strpos ($_server[' http_user_agent ', ' Micromessenger ')!== false) { return true; } else { return false;} }
The above is the whole content of this article, I hope that everyone's study has helped.