我正在用 PHP 编写一个网站.由于网络上的任何人都需要访问它才能访问互联网,因此我必须创建一个移动版本.我如何最好地检查它是否是移动设备?我不想在最后有 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 的移动设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!