php判断客户端类型

1.composer第三方扩展包 jenssegers/agent

2.使用composer安装

composer require jenssegers/agent

2.1在config\app.php中注册服务提供者

Add the service provider in config/app.php:

Jenssegers\Agent\AgentServiceProvider::class,

And add the Agent alias to config/app.php:

'Agent' => Jenssegers\Agent\Facades\Agent::class,

3.在控制器中的使用

3.1引用类

use Jenssegers\Agent\Agent;

3.2实例化Agent对象

$agent = new Agent();

3.3运用实例化之后对象的判断

Agent::is('Windows');
Agent::is('Firefox');
Agent::is('iPhone');
Agent::is('OS X');

3.4,第二种判断方式

Agent::isAndroidOS();
Agent::isNexus();
Agent::isSafari();
posted @ 2020-06-26 11:40  以己为镜  阅读(346)  评论(0编辑  收藏  举报