判断是移动端还是PC端

// 判断是移动端还是PC端

  
$http_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? strtolower($_SERVER['HTTP_USER_AGENT']): '';
$http_accept = isset($_SERVER['HTTP_ACCEPT']) ? strtolower($_SERVER['HTTP_ACCEPT']): '';
$pos_hua = strpos($http_user_agent, 'mobi');
$pos_a_wap = strpos($http_accept, 'wap');
$pos_a_wml = strpos($http_accept, 'wml');
  
if($pos_hua !== FALSE) {
    echo 'Mobile';//exit;
} elseif($pos_a_wap !== FALSE) {
    echo 'Mobile';//exit;
} elseif($pos_a_wml !== FALSE) {
    echo 'Mobile';//exit;
} else {
    echo 'PC';
}

 

posted @ 2014-08-28 12:06  huidaoli  阅读(342)  评论(0编辑  收藏  举报