bradstinson/uaparser

用户代理解析库

0.0.1 2012-12-04 19:55 UTC

This package is not auto-updated.

Last update: 2024-09-22 03:36:46 UTC


README

注意:此代码不再维护或支持。我建议使用以下包代替:https://packagist.org.cn/packages/ua-parser/uap-php

UAParser利用了浏览器检测库"ua-parser-php"。(https://github.com/tobie/ua-parser/tree/master/php)

我无法为原始库获得任何荣誉,我只是将其封装起来,使其仅通过静态调用工作。

用法

以下函数可用于使用

echo UserAgent::full();
// -> Chrome 16.0.912/Mac OS X 10.6.8

echo UserAgent::browserFull();
// -> "Chrome 16.0.912"

echo UserAgent::browser();
// -> "Chrome"

echo UserAgent::version();
// -> "16.0.912"

echo UserAgent::major();
// -> 16 (minor, build, & revision also available)

echo UserAgent::osFull();
// -> "Mac OS X 10.6.8"

echo UserAgent::os();
// -> "Mac OS X"

echo UserAgent::osVersion();
// -> "10.6.8"

echo UserAgent::osMajor();
// -> 10 (osMinor, osBuild, & osRevision also available)

/* 
* in select cases the device information will also be captured
*/

echo UserAgent::deviceFull();
// -> "Palm Pixi 1.0"

echo UserAgent::device();
// -> "Palm Pixi"

echo UserAgent::deviceVersion();
// -> "1.0"

echo UserAgent::deviceMajor();
// -> 1 (deviceMinor also available)

/*
* Some other generic boolean options
*/

echo UserAgent::isMobile();
// -> (would return true if the browser met the criteria of a mobile browser based on the user agent information)

echo UserAgent::isMobileDevice();
// -> (would return true if the device met the criteria of a mobile device based on the user agent information)

echo UserAgent::isTablet();
// -> (would return true if the device was a tablet according to the user agent information)

echo UserAgent::isSpider();
// -> (would return true if the device was a spider according to the user agent information)

echo UserAgent::isComputer();
// -> (would return true if the device was a computer according to the user agent information)

echo UserAgent::isUIWebview();
// -> (would return true if the user agent was from a uiwebview in ios)

此资产库受到了以下库的启发并使用了它们的组件