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 的移动设备?
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
