Http://www.thinkphp.cn/code/2107.html
/* Mobile End Judge/Function ismobile () { // If Http_x_wap_profile 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 and some service providers will block the information if (isset ($_server[' Http_via ')) { // not found for flase, otherwise true return Stristr ($_server[' Http_via '], "WAP") ? true : false; } // brain Residue method, to judge the mobile phone to send the client logo, 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 ' ); // from Http_user _agent keyword if (preg_match ("/" . implode) for mobile browsers (' | ', $clientkeywords) . ")/I", strtolower ($_server[' http_user_agent '))) { Return truE } } Protocol law, because it may be inaccurate, 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;