• 自动识别wap和web栗子(1812)
    作曲/百科库/2015/02/28 23:22
    鸣谢紫殇!
    $agent = strtolower($_SERVER[
    'HTTP_USER_AGENT']);
    $iphone = (strpos($agent, 'iphone')) ? true : false;
    $ipad = (strpos($agent, 'ipad')) ? true : false;
    $android = (strpos($agent, 'android')) ? true : false;
    if($iphone || $ipad){
    echo 'you phone is iPhone or iPad';
    }else if($android){
    echo 'you phone is android';
    }else{
    echo 'you phone is Windows or Linux or other';
    }


    法2,感谢学c

    function check_wap(){
    // 先检查是否为wap代理,准确度高
    if(stristr($_SERVER['HTTP_VIA'],"wap")){
    return true;
    }
    // 检查浏览器是否接受 WML.
    elseif(strpos(strtoupper($_SERVER['HTTP_ACCEPT']),"VND.WAP.WML") > 0){
    return true;
    }
    //检查USER_AGENT
    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'])){
    return true;
    }
    else{
    return false;
    }
    }
    if(check_wap()){
    include 'wapcss.css';
    }else{
    include 'webcss.css';
    }
操作:该文章你无法操作
【回复列表】
游客/@Ta/2015/03/27 21:11
Immortal
游客/@Ta/2015/03/27 20:52
123456
页:1
登陆后可以评论小编得文章奥!

返回首页