How do I determine whether it#39;s a mobile device with PHP?(如何确定它是否是带有 PHP 的移动设备?)
问题描述
我正在用 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 的移动设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何确定它是否是带有 PHP 的移动设备?


基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- 在多维数组中查找最大值 2021-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01