判断是移动端还是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‘;
}

 

判断是移动端还是PC端

上一篇:iOS开发之状态栏隐藏(问题篇)


下一篇:Android项目-几种常见的应用架构