我正在用 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模板网!
以编程方式将可下载文件添加到 Woocommerce 产品Add programmatically a downloadable file to Woocommerce products(以编程方式将可下载文件添加到 Woocommerce 产品)
获取今天 Woocommerce 中每种产品的总订单数Get today#39;s total orders count for each product in Woocommerce(获取今天 Woocommerce 中每种产品的总订单数)
在 WooCommerce 和电话字段验证问题中添加自定义注Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和电话字段验证问题中添加自定义注册字段
在 Woocommerce 简单产品中添加一个将更改价格的选Add a select field that will change price in Woocommerce simple products(在 Woocommerce 简单产品中添加一个将更改价格的选择字段)
在 WooCommerce 3 中将自定义列添加到管理产品列表Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中将自定义列添加到管理产品列表)
自定义结帐“下订单"按钮输出htmlCustomizing checkout quot;Place Orderquot; button output html(自定义结帐“下订单按钮输出html)