使用PHP / Javascript重定向移动设备的单个php页面的最佳方法 [英] Best way to redirect single php page for mobile devices with PHP/Javascript

查看:103
本文介绍了使用PHP / Javascript重定向移动设备的单个php页面的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个PHP谷歌地图应用程序,我想让用户在使用桌面时可见,但如果访问者使用的是移动设备,则会重定向到另一个PHP页面。我知道从操作系统到浏览器类型检测有很多方法可以做到这一点,但是想知道是否有人可以提供一些代码,他们觉得这是处理这个问题的最佳方法,它是最一致的吗?

I have a PHP google map application that I want to make visible to users when they are using a desktop but redirect to another PHP page if the visitor is using a mobile device. I know there are numerous ways to do this from OS to browser type detection but was wondering if someone could provide some code they feel is the best way to handle this and it being the most consistent?

推荐答案

如果您不想使用javascript,可以通过php处理它。
看一下这个库: http://code.google.com / p / PHP-移动检测/
然后你可以这样做:

If you don't want to use javascript, you can handle it via php. Take a look at this lib: http://code.google.com/p/php-mobile-detect/. And then you could do something like:

<?php
include 'Mobile_Detect.php';
$detect = new Mobile_Detect();

if ($detect->isMobile()) {
    header('Location: yourpage.php');
    exit(0);
}

这篇关于使用PHP / Javascript重定向移动设备的单个php页面的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆