functionIsMobile () {if(isset($_server[' Http_x_wap_profile '])) {//If you have http_x_wap_profile, it must be a mobile device . return true; } if(isset($_server[' Http_via '])) {//if the VIA message contains a WAP, it must be a mobile device, and some service providers block that information return Stristr($_server[' Http_via '], "WAP")?true:false;//not found for flase, otherwise true } if(isset($_server[' Http_user_agent '])){ $clientkeywords=Array(' Nokia ', ' Sony ', ' Ericsson ', ' mot ', ' Samsung ', ' HTC ', ' SGH ', ' lg ', ' sharp ', ' sie-', ' Philips ', ' Panasonic ', ' Alcatel ', ' Le Novo ', ' iphone ', ' ipod ', ' blackberry ', ' Meizu ', ' Android ', ' NetFront ', ' Symbian ', ' UCWeb ', ' windowsce ', ' palm ', ' Operamini ', ' operamobi ', ' Openwave ', ' nexusone ', ' cldc ', ' MIDP ', ' wap ', ' mobile '); if(Preg_match("/(" .implode(' | ',$clientkeywords) . ")/I",Strtolower($_server[' Http_user_agent ']))){ return true; } } if(isset($_server[' http_accept '])) {//protocol law, because there may be inaccuracies, put to the final Judgment 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 is judged to be mobile or PC-side