Home  >  Article  >  php教程  >  PHP实现根据设备类型自动跳转相应页面的方法

PHP实现根据设备类型自动跳转相应页面的方法

WBOY
WBOYOriginal
2016-06-06 20:19:48771browse

这篇文章主要介绍了PHP实现根据设备类型自动跳转相应页面的方法,是非常实用的功能,需要的朋友可以参考下

随着当今移动设备的普及,上网已经比过去更加方便。针对Android智能手机,iPhone/iPad等移动终端,很多网站都相继推出了针对电脑和这类手机等移动设备访问的网页。本文所述的实例代码就可以实现根据这些移动设备终端而自动跳转到适合它们浏览的页面。即判断PC端或手机站智能端并跳转。

完整的实例代码如下:

window.location.href='pc.html'";//这里也可以是网址 } if($android){ echo "";//这里也可以是网址 } ?>

这里使用PHP中的内置函数HTTP_USER_AGENT获取客户端设备类型,再使用字符串处理函数对其提取,,然后判断是什么设备,根据设备自动定位到适合的网页或页面发送给客户端。

Statement:
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