Take the SP framework as an example: <?phpclass main extends Spcontroller//main is a PC-side ingress controller, equivalent to the default Indexcontroller.php{function __construct () { Parent::__construct (); if ($this->ismobile ()) { //redirect to mobile header (" Location:http://$_server[http_host]/mobile.php "); mobile.php for mobile port entry files exit; }else{ .... } } <?php class Spcontroller { /** * Whether mobile Access * * @return bool */ public function IsMobile () { //If you have 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 this information if (isset ($_server[' Http_via ')) { //not found for flase, otherwise true return 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 ', &NB Sp ' Sony ', ' Ericsson ', and nbsp; ' Mot ', ' Samsung ', ' HTC ',   ; ' SGH ', ' LG ', & nbsp ' sharp ', ' sie-', &NBS P ' Philips ', ' Panasonic ', &NBS P; ' Alcatel ', ' Lenovo ', ' IphonE ', ' ipod ', ' BlackBerry ', &NB Sp ' Meizu ', ' Android ', & nbsp ' NetFront ', ' Symbian ', &NBSP ; ' UCWeb ', ' WindowsCE ', ' palm ', ' Operamini ', ' Operamobi ', ' Openwave ', &N BSP; ' Nexusone ', ' CLDC ', ' MIDP ', &N Bsp ' WAP ', ' mobile ' &NBSP ; ); //find mobile browser keywords from http_user_agent if (Preg_match ("/("). Implode (' | ', $clientkeywords). ")/I", Strtolower ($_server[' http_user_agent '))) { nbsp return true; } } //protocol, as it may be inaccurate and put to the final Judgment & nbsp if (isset ($_server[' http_accept ')) { // If only WML is supported and HTML is not supported then it must be mobile //if WML and HTML are supported, but WML is mobile 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; &NBsp } } return false; }
Determine if the Mobile Access Access "PHP"