当前位置:Gxlcms > PHP教程 > php怎么判断手机客户端访问?

php怎么判断手机客户端访问?

时间:2021-07-01 10:21:17 帮助过:34人阅读

  1. // check if wap
  2. function check_wap(){
  3. if(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高
  4. return true;
  5. }elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){// 检查浏览器是否接受 WML.
  6. return true;
  7. }elseif(preg_match('/(blackberry|configuration\/cldc|hp |hp-|htc |htc_|htc-|iemobile|kindle|midp|mmp|motorola|mobile|nokia|opera mini|opera |Googlebot-Mobile|YahooSeeker\/M1A1-R2D2|android|iphone|ipod|mobi|palm|palmos|pocket|portalmmm|ppc;|smartphone|sonyericsson|sqh|spv|symbian|treo|up.browser|up.link|vodafone|windows ce|xda |xda_)/i', $_SERVER['HTTP_USER_AGENT'])){//检查USER_AGENT
  8. return true;
  9. }else{
  10. return false;
  11. }
  12. }

人气教程排行