PHP to determine the mobile phone computer access automatic jumping head file code as follows:
<?php function is_mobile_request () { $_server[' all_http '] = isset ($_server[' all_http ']) ? $_server[' all_http '] : ' '; $mobile _ browser = ' 0 '; if (Preg_match ('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap| Phone|iphone|ipad|ipod|android|xoom)/I ', strtolower ($_server[' http_user_agent ')) $mobile _browser++; if (isset ($_server[' http_accept ')) and Strpos (strtolower ($_server[' http_accept ']), ' application/vnd.wap.xhtml+xml ') !== false) $ mobile_browser++; if (isset ($_server[' http_x_wap_profile ')) $mobile _ browser++; if (isset ($_server[' http_profile ')) $mobile _browser++;
$mobile _ua = strtolower (substr ($_server[' http_user_agent '],0,4)); $mobile _agents = array ( ' w3c ', ' acs-', ' Alav ', ' Alca ', ' amoi ', ' Audi ', ' Avan ', ' BenQ ') , ' bird ', ' Blac ', ' Blaz ', ' brew ', ' cell ', ' cldc ', ' cmd-', ' Dang ', ' doco ', ' Eric ', ' Hipt ', ' Inno ', ' iPAQ ', ' Java ', ' Jigs ', ' kddi ', ' Keji ', ' Leno ', ' lg-c ', ' lg-d ', ' Lg-g ', ' lge-', ' Maui ', ' Maxo ', ' MIDP ', ' mits ', ' mmef ', ' mobi ', ' mot-', ' Moto ', ' MWBP ', ' nec-', ' Newt ', ' Noki ', ' oper ', ' palm ', ' pana ', ' Pant ', ' Phil ', ' play ', ' Port ', ' ProX ', ' qwap ', ' sage ', ' Sams ', ' Sany ', ' sch-', ' sec-', ' send ', ' Seri ', ' sgh-', ' Shar ', ' sie-', ' Siem ', ' smal ', ' Smar ', ' Sony ', ' sph-', ' symb ', ' t-mo ', ' Teli ', ' tim-', ' tosh ', ' tsm-', ' upg1 ', ' upsi ', ' vk-v ', ' Voda ', ' wap-', ' wapa ', ' Wapi ', ' Wapp ', ' wapr ', ' webc ', ' winw ', ' winw ', ' xda ', ' xda-' ); if(In_array ($mobile _ua, $mobile _agents)) $mobile _browser++; if ( Strpos (Strtolower ($_server[' all_http '), ' Operamini ') !== false) $mobile _browser++; // pre-final check to reset everything if the user is on Windows if (Strpos strtolower ($_server[' http_user_agent '), ' windows ') !== false $mobile _browser=0; // but wp7 is also windows, with a slightly different characteristic if (Strpos (Strtolower ($_server[' http_user_agent ')), ' Windows phone ') !== False) $mobile _browser++; if ($mobile _browser>0)
return true; else return false; } if (is_mobile_requesT ()) { header ("location:app/index.html"), Exit (),} else{ header ("location:index/index.html"), exit (); }?>
The above is PHP to determine the mobile phone computer access to automatically jump the file code, the need for small partners, can be modified according to the actual needs.