php判断客户端类型

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

2.使用composer安装

composer require jenssegers/agent

2.1在configapp.php中注册服务提供者

Add the service provider in config/app.php:

JenssegersAgentAgentServiceProvider::class,

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

'Agent' => JenssegersAgentFacadesAgent::class,

3.在控制器中的使用

3.1引用类

use JenssegersAgentAgent;

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();
原文地址:https://www.cnblogs.com/yaoliuyang/p/13194282.html