如何确定它是否是带有PHP的移动设备? [英] How do I determine whether it's a mobile device with PHP?

查看:71
本文介绍了如何确定它是否是带有PHP的移动设备?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用PHP编写网站.由于网络上的任何人都需要访问它才能访问Internet,因此我必须创建一个移动版本.如何最好地检查它是否是移动设备?我不希望最后有50个设备的switch语句,因为我不仅想支持iPhone.

I am writing a website with PHP. Since it will need to be accessed by anyone on the network to access the internet I have to create a mobile version. How do I best check if it's a mobile device? I don't want to have a switch statement with 50 devices at the end since I don't only want to support the iPhone.

我可以使用一个PHP类吗?

Is there a PHP class I could use?

推荐答案

您需要检查客户端发送的多个标头,例如USER_AGENT和HTTP_ACCEPT.请查看本文,以获取有关移动用户代理的全面检测脚本,网址为PHP.

You need to check several headers that the client sends, such as USER_AGENT and HTTP_ACCEPT. Check out this article for a comprehensive detection script for mobile user-agents in PHP.

这篇关于如何确定它是否是带有PHP的移动设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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