25 | } 再来一个从PHP框架剥离的判断是否为手机移动终端的函数:
01 | function is_mobile_request() |
03 | $_SERVER['ALL_HTTP'] = isset($_SERVER['ALL_HTTP']) ? $_SERVER['ALL_HTTP'] : ''; |
04 | $mobile_browser = '0'; |
05 | if(preg_match('/(up.browser|up.link|mmp|symbian|smartphone|midp|wap|phone|iphone|ipad|ipod|android|xoom)/i', strtolower($_SERVER['HTTP_USER_AGENT']))) |
07 | if((isset($_SERVER['HTTP_ACCEPT'])) and (strpos(strtolower($_SERVER['HTTP_ACCEPT']),'application/vnd.wap.xhtml+xml') !== false)) |
09 | if(isset($_SERVER['HTTP_X_WAP_PROFILE'])) |
11 | if(isset($_SERVER['HTTP_PROFILE'])) |
13 | $mobile_ua = strtolower(substr($_SERVER['HTTP_USER_AGENT'],0,4)); |
14 | $mobile_agents = array( |
15 | 'w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac', |
16 | 'blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno', |
17 | 'ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-', |
18 | 'maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-', |
19 | 'newt','noki','oper','palm','pana','pant','phil','play','port','prox', |
20 | 'qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar', |
21 | 'sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-', |
22 | 'tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp', |
23 | 'wapr','webc','winw','winw','xda','xda-' |
25 | if(in_array($mobile_ua, $mobile_agents)) |
27 | if(strpos(strtolower($_SERVER['ALL_HTTP']), 'operamini') !== false) |
30 | if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows') !== false) |
33 | if(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'windows phone') !== false) |
|