Home > Backend Development > PHP Tutorial > device - PHP 以判断移动设备跳转,怎么回跳?

device - PHP 以判断移动设备跳转,怎么回跳?

WBOY
Release: 2016-06-06 20:41:59
Original
1157 people have browsed it

<code>require(dirname(__FILE__)."/lib/Mobile_Detect.php");
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

if($_SERVER["SERVER_NAME"] == "nj.xxx.cn" ){        
    if($deviceType == "phone") {
        header("Location:http://m.xxx.cn/");
        exit();
    }
}
</code>
Copy after login
Copy after login

已经判断移动设备

在手机端点使用电脑版 应该怎么处理

回复内容:

<code>require(dirname(__FILE__)."/lib/Mobile_Detect.php");
$detect = new Mobile_Detect;
$deviceType = ($detect->isMobile() ? ($detect->isTablet() ? 'tablet' : 'phone') : 'computer');

if($_SERVER["SERVER_NAME"] == "nj.xxx.cn" ){        
    if($deviceType == "phone") {
        header("Location:http://m.xxx.cn/");
        exit();
    }
}
</code>
Copy after login
Copy after login

已经判断移动设备

在手机端点使用电脑版 应该怎么处理

写session或者cookie,记录客户已经点击了使用电脑版本,然后在判断移动设备的地方加上session判断

Related labels:
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