欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

PHP判断是否为手机客户端,PHP判断手机客户端_PHP教程

程序员文章站 2022-05-19 23:13:42
...

PHP判断是否为手机客户端,PHP判断手机客户端


function check_wap(){
    if(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高
        return true;
    }elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){// 检查浏览器是否接受 WML.
        return true;
   }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
        return true;             
    }else{
        return false;    
   }
   
}
if(check_wap() && !$_GET['m']){
    Header('Location:http://www.sdceo.com/?m=wap');
}
?>
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
html xmlns="http://www.w3.org/1999/xhtml">
head>
meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
title>php判断是否手机客户端title>
head>

body>

body>
html>

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1056600.htmlTechArticlePHP判断是否为手机客户端,PHP判断手机客户端 ? function check_wap(){ if(stristr($_SERVER['HTTP_VIA'],"wap")){// 先检查是否为wap代理,准确度高 return tr...
相关标签: php