Today see a PHP to determine whether it is a handheld device code,
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 VIA information contains WAP, it must be a mobile device, some service associations block the information if (isset ($_server[' Http_via ')) {// cannot be found as flase, Otherwise truereturn stristr ($_server[' Http_via '], "WAP") ? true : false;} Brain residue method, determine 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 ', &NBsp; ' Symbian ', ' UCWeb ', ' windowsce ', ' palm ', ' Operamini ', ' Operamobi ', ' Openwave ', ' Nexusone ', ' CLDC ', ' MIDP ', ' WAP ', ' mobile ' ); // Find the keywords in the phone browser from http_user_agent if (Preg_match ("/(" . implode (' | '), $ clientkeywords) . ")/I", strtolower ($_server[' http_user_agent '))) { return true; }}// Agreement Law, Because there may be inaccuracies, put to the Last Judgment if (isset ($_server[' http_accept ')) {// if only WML is supported and HTML is not supported that must be a mobile device// If WML and HTML are supported but WML before HTML is 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;}
PHP to determine if the current browsing device is a mobile phone