Code One:
Copy CodeThe code is as follows:
function Check_wap () {
if (Isset ($_server[' Http_via ')) return true;
if (Isset ($_server[' Http_x_nokia_connection_mode ')) return true;
if (Isset ($_server[' http_x_up_calling_line_id ')) return true;
if (Strpos (Strtoupper ($_server[' http_accept ')), "VND. Wap. WML ") > 0) {
Check whether the Browser/gateway says it accepts WML.
$BR = "WML";
} else {
$browser = isset ($_server[' http_user_agent ')? Trim ($_server[' http_user_agent '): ";
if (empty ($browser)) return true;
$mobile _os_list=array (' Google Wireless transcoder ', ' Windows CE ', ' windowsce ', ' Symbian ', ' Android ', ' armv6l ', ' armv5 ', ' Mobile ', ' CentOS ', ' mowser ', ' AvantGo ', ' Opera Mobi ', ' J2ME/MIDP ', ' Smartphone ', ' go.web ', ' Palm ', ' IPAQ ');
$mobile _token_list=array (' PROFILE/MIDP ', ' configuration/cldc-', ' 160x160 ', ' 176x220 ', ' 240x240 ', ' 240x320 ', ' 320x ' Up. ' Browser ', ' up. Link ', ' SymbianOS ', ' PalmOS ', ' PocketPC ', ' SonyEricsson ', ' Nokia ', ' BlackBerry ', ' Vodafone ', ' BenQ ', ' novarra-vision ', ' Iris ', ' NetFront ', ' htc_ ', ' Xda_ ', ' samsung-sgh ', ' Wapaka ', ' DoCoMo ', ' iPhone ', ' iPod ';
$found _mobile=checksubstrs ($mobile _os_list, $browser) | |
Checksubstrs ($mobile _token_list, $browser);
if ($found _mobile)
$BR = "WML";
else $BR = "WWW";
}
if ($br = = "WML") {
return true;
} else {
return false;
}
}
function Checksubstrs ($list, $str) {
$flag = false;
for ($i =0; $i if (Strpos ($str, $list [$i]) > 0) {
$flag = true;
Break
}
}
return $flag;
}
if (Check_wap ()) {
echo "WAP";
}else{
echo "Web";
}
?>
Code two:
Copy CodeThe code is as follows:
Header ("Content-type:text/html;charset=utf-8");
function Is_mobile () {
$user _agent = $_server[' http_user_agent ');
$mobile _agents = Array ("240x320", "Acer", "Acoon", "acs-", "Abacho", "Ahong", "Airness", "Alcatel", "Amoi", "Android", " Anywhereyougo.com "," applewebkit/525 "," applewebkit/532 "," Asus "," Audio "," Au-mic "," Avantogo "," Becker "," BenQ "," Bilbo "," Bird "," BlackBerry "," blazer "," Bleu "," cdm-"," Compal "," Coolpad "," Danger "," Dbtel "," Dopod "," Elaine "," Eric ", "Etouch", "Fly", "Fly_", "fly-", "Go.web", "goodaccess", "Gradiente", "Grundig", "Haier", "Hedy", "Hitachi", "HTC", " Huawei "," Hutchison "," Inno "," ipad "," iPAQ "," ipod "," Jbrowser "," KDDI "," kgt "," KWC "," Lenovo "," LG "," Lg2 "," Lg3 "," LG4 ", "Lg5", "Lg7", "Lg8", "Lg9", "lg-", "lge-", "Lge9", "Longcos", "Maemo", "Mercator", "Meridian", "Micromax", "MIDP", "Mini", " Mitsu "," MMM "," MMP "," Mobi "," mot-"," Moto "," nec-"," NetFront "," Newgen "," Nexian "," Nf-browser "," Nintendo "," Nitro "," Nokia "," Nook "," Novarra "," Obigo "," Palm "," Panasonic "," Pantech "," Philips "," Phone "," pg-"," PlayStation "," Pocket "," Pt-"," qc-"," Qtek "," Rover "," Sagem "," sama "," Samu "," Sanyo "," Samsung "," sch-"," Scooter "," sec-"," Sendo "," sgh-"," Sharp "," Siemens "," sie-"," SoftBank "," Sony "," Spice "," Sprint "," SPV "," Symbian "," tablet "," Talkabout "," tcl-"," Teleca "," Telit "," Tianyu "," Tim-"," Toshiba "," TSM "," Up.browser "," Utec "," Utstar "," Verykool "," Virgin "," vk-"," Voda "," Voxtel "," VX "," WAP "," Wellco "," Wig Browser "," Wii "," Windows CE "," wireless "," XDA "," Xde "," ZTE ");
$is _mobile = false;
foreach ($mobile _agents as $device) {
if (Stristr ($user _agent, $device)) {
$is _mobile = true;
Break
}
}
return $is _mobile;
}
if (Is_mobile ()) {
echo "mobile";
}else{
echo "Computer";
}
http://www.bkjia.com/PHPjc/326813.html www.bkjia.com true http://www.bkjia.com/PHPjc/326813.html techarticle code One: Copy the code as follows:? PHP function Check_wap () {if (Isset ($_server[' Http_via ')) return true; if (Isset ' $_server[ Okia_connection_mode '])) return true; I ...