foursking
V2EX  ›  PHP

求助如何判断访问来源是否为手机,求手机 HTTP_USER_AGENT 列表

  •  
  •   foursking · Feb 10, 2014 · 6181 views
    This topic created in 4651 days ago, the information mentioned may be changed or developed.
    RT,需要判断来源手机(不包括pad !!! ipad 三星系列 ...) 目前想到的方法是整理所有的设备号,然后做过滤. 不知道是否有更好的方法
    10 replies  •  1970-01-01 08:00:00 +08:00
    zencoding
    zencoding
    Feb 10, 2014❤️1
    3
    $mobile_agents = array('w3c ','acs-','alav','alca','amoi','audi','avan','benq','bird','blac','blaz','brew','cell','cldc','cmd-','dang','doco','eric','hipt','inno','ipaq','java','jigs','kddi','keji','leno','lg-c','lg-d','lg-g','lge-','maui','maxo','midp','mits','mmef','mobi','mot-','moto','mwbp','nec-','newt','noki','oper','palm','pana','pant','phil','play','port','prox','qwap','sage','sams','sany','sch-','sec-','send','seri','sgh-','shar','sie-','siem','smal','smar','sony','sph-','symb','t-mo','teli','tim-','tosh','tsm-','upg1','upsi','vk-v','voda','wap-','wapa','wapi','wapp','wapr','webc','winw','winw','xda','xda-'
    );
    explon
    explon
    Feb 10, 2014❤️1
    4
    function is_mobile()
    {
    $user_agent = strtolower($_SERVER['HTTP_USER_AGENT']);

    if (preg_match('/playstation/i', $user_agent) OR preg_match('/ipad/i', $user_agent) OR preg_match('/ucweb/i', $user_agent))
    {
    return false;
    }

    if (preg_match('/iemobile/i', $user_agent) OR preg_match('/mobile\ssafari/i', $user_agent) OR preg_match('/iphone\sos/i', $user_agent) OR preg_match('/android/i', $user_agent) OR preg_match('/symbian/i', $user_agent) OR preg_match('/series40/i', $user_agent))
    {
    return true;
    }

    return false;
    }
    zenxds
    zenxds
    Feb 10, 2014❤️1
    5
    /(iPod|iPhone|Android|Opera Mini|BlackBerry|webOS|UCWEB|Blazer|PSP|IEMobile|Symbian)/gi
    foursking
    foursking
    OP
    Feb 10, 2014
    6
    @xream pad 系列能过滤掉吗 谢谢
    foursking
    foursking
    OP
    Feb 10, 2014
    7
    @explon 能否过滤 三星 pad 系列
    foursking
    foursking
    OP
    Feb 10, 2014
    8
    @megaforce 多谢 测试可以使用
    regent
    regent
    Feb 10, 2014
    9
    我之前用的一个方法是,把WordPress上面的移动版面插件打开看看,里面有关于UA的判断
    vibbow
    vibbow
    Feb 11, 2014
    10
    UA识别大全: http://browscap.org/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4894 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 57ms · UTC 07:18 · PVG 15:18 · LAX 23:18 · JFK 02:18
    ♥ Do have faith in what you're doing.