<?phpfunction is_mobile () { //Regular expression, batch with different mobile browser UA keywords. $regex _match= "/(Nokia|iphone|android|motorola|^mot\-|softbank|foma|docomo|kddi|up\. Browser|up\.link| "; $regex _match.= "htc|dopod|blazer|netfront|helio|hosin|huawei|novarra| Coolpad|webos|techfaith|palmsource| "; $regex _match.= "blackberry|alcatel|amoi|ktouch|nexian|samsung|^sam\-|s[cg]h|^lge|ericsson| Philips|sagem|wellcom|bunjalloo|maui| "; $regex _match.= "Symbian|smartphone|midp|wap|phone|windows ce|iemobile|^spice|^bird|^zte\-| Longcos|pantech|gionee|^sie\-|portalmmm| "; $regex _match.= "jig\s browser|hiptop|^ucweb|^benq|haier|^lct|opera\s*mobi|opera\*mini|320x320| 240x320|176x220 "; $regex _match.=")/I "; return isset ($_ server[' Http_x_wap_profile ') or isset ($_server[' http_profile ']) or Preg_match ($regex _match, Strtolower ($_server[' Http_user_agent '])); If there is a above-mentioned close in the UAThe key word returns TRUE. } if (Is_mobile ()) { //If True, the WAP page. Header ("http/1.1 301 Moved Permanently"); Header ("location:http://www.966266.com/wap.php"); }else { //If False, make a Web page. header ("http/1.1 301 Moved Permanently"); header ("location:http://www.966266.com/"); }?>
PHP server-side check phone access or PC access (and jump to different pages)