isMobileDevice()) print "This mobile."; else print "This is not a mobile."; */ class MobileDevice { function isMobileDevice(){ $detector = array( "Windows CE", "Nokia", "Motorola", "Smartphone", "SonyEriccson", "Android", "iPod", "iPad", "iPhone", "Mobile Safari", "Blazer", "HandSpring", "BlackBerry", "Kyocera", "PPC", "PDA", "Pocket", "CellPhone", "MobilePhone", "Palm", "PalmOS", "PalmSource", "Symbian OS", "SymbianOS", "Opera Mini", "Opera Mobile", "Opera 6.0", "AvantGo", "NetFront", "Obigo", "UP.Browser", "UP.Link", "Maemo", "MIDP", "CLCD", "DoCoMo", "WAP", "EPOC", "PS2", "PSP", "PlayStation Portable", "Mobile Content Viewer", "RegKing", "Googlebot-Mobile", "iemobile", "portalmmm" ); $user_agents = array( 'Vodafone/1.0/V802SE/SEJ001 Browser/SEMC-Browser/4.1', 'Mozilla/3.0(DDIPOCKET;JRC/AH-J3001V,AH-J3002V/1.0/0100/c50)CNF/2.0', 'PDXGW/1.0 (TX=8;TY=6;GX=96;GY=64;C=G2;G=B2;GI=0)', 'ASTEL/1.0/J-0511.00/c10/smel', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; ca; rv:1.5)', 'Xiino/1.0.9E [en] (v. 4.1; 153x130; g4)', 'Gecko/20031007', 'Plucker/Py-1.4', 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)', 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT) (compatible; MSIE 5.5; Windows NT)', 'SEC-SGHD410', 'Mozilla/4.0 (compatible; MSIE 6.0; j2me) ReqwirelessWeb/3.5', 'AU-MIC/1.1.4.0 20722 MMP/2.0', 'ReqwirelessWeb/3.2 S55', 'Mozilla/4.74 [en] (X11; I; ProxiNet)', 'Mozilla/2.0 (compatible; Elaine/3.0)', 'SAMSUNG-SGH-A300/1.0 UP/4.1.19k', 'SEC-SGHE710/1.0' ); $is_mobile = false; $i = 0; $ua = $_SERVER['HTTP_USER_AGENT']; while(($i < count($detector)) and ($is_mobile == false)){ preg_match_all("/".$detector[$i]."/i", $ua, $matches); if(count($matches[0])>0) $is_mobile = true; $i++; } if(!$is_mobile) $is_mobile = in_array($ua, $user_agents); return $is_mobile; } } ?>