flextype-components / agent
Agent 组件提供了一种简单的方法来检测发出请求的设备类型。
v1.1.1
2018-04-12 11:49 UTC
Requires
- php: ^7.1.3
This package is auto-updated.
Last update: 2024-08-25 11:24:38 UTC
README
Agent 组件提供了一种简单的方法来检测发出请求的设备类型。
安装
composer require flextype-components/agent
使用
use Flextype\Component\Agent\Agent;
如果发出请求的用户代理被识别为移动设备,则返回 true。
if (Agent::isMobile()) { // Do something... }
如果发出请求的用户代理被识别为机器人/爬虫,则返回 true。
if (Agent::isRobot()) { // Do something... }
如果你正在寻找的字符串存在于用户代理字符串中,则返回 TRUE,否则返回 FALSE。
if (Agent::is('iphone')) { // Do something... } if (Agent::is(array('iphone', 'ipod'))) { // Do something... }
许可证
查看 LICENSE