Home > Backend Development > PHP Tutorial > 现在用什么技术识别是PC访问还是手机访问?

现在用什么技术识别是PC访问还是手机访问?

WBOY
Release: 2016-06-23 14:26:52
Original
961 people have browsed it

wap 手机

现在用什么技术识别是PC访问还是手机访问?如题

回复讨论(解决方案)

一般是看发送的header吧。

还有就是分辨率,对小屏幕而言。

print_r($_SERVER);

你用不同的设备去访问你的网站,看一下不就知道了

楼上说的很对。

$_SERVER['HTTP_USER_AGENT'];

赞!!!  赶紧试试去

$ua = strtolower($_SERVER['HTTP_USER_AGENT']);

$uachar = "/(nokia|sony|ericsson|mot|samsung|sgh|lg|philips|panasonic|alcatel|lenovo|cldc|midp|mobile|ipad|iphone|android)/i";

if(($ua == '' || preg_match($uachar, $ua))&& !strpos(strtolower($_SERVER['REQUEST_URI']),'wap'))
{
        //手机访问 
header("Location: m.manshijian.com"); 
exit;
}else{
       //pc
}

http://www.16code.com/webapp-developer/

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template