zsxsoft/php-useragent

此包已被废弃且不再维护。没有建议的替代包。

用户代理分析项目。

1.5 2018-06-15 07:58 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:09:48 UTC


README

Build Status Latest Stable Version Codacy Badge Packagist

用户代理分析项目。

尝试使用

http://www.zsxsoft.com/php-useragent/test-my-useragent.php

JavaScript 版本

https://github.com/zsxsoft/useragent.js/

贡献者

zsx(http://www.zsxsoft.com)

本项目基于 kyleabaker 的 "wp-useragent"。

支持的浏览器/平台

点击此处查看完整列表。

测试过的浏览器:Amazon Silk / Android Webkit / Avant Browser / Comodo Dragon / curl / Firefox / Google Chrome / Internet Explorer / Microsoft Edge / Links / Lynx / Maxthon / MxNitro / Opera / QQBrowser / Safari SRWare Iron / Teleca Q7 / UC Browser / Vivaldi / W3M / wget / Yandex.Browser 等。

操作系统:Android / Arch Linux / CentOS / Chrome OS / Debain / Fedora / FreeBSD / OSX / Red Hat / openSUSE / SymbianOS / Unix / Palm webOS / Windows 3.1 - 10 / Ubuntu / Linux 等。

设备:小米 / 黑莓 / Nexus / HTC / 华为 / Kindle / 联想 / LG / 摩托罗拉 / 诺基亚 / OnePlus / PlayStation / 三星 / 索尼 Xperia / 中兴 / Ubuntu / Windows Phone / 苹果系列等。

示例 & API

<?php
/**
 * Test Useragent
 * @package php-useragent
 * @author zsx <zsx@zsxsoft.com>
 * @license GNU/GPL https://gnu.ac.cn/copyleft/gpl.html
 */
ini_set('display_errors', 'On');
error_reporting(E_ALL);
include './useragent.class.php';
$useragent = UserAgentFactory::analyze($_SERVER['HTTP_USER_AGENT']);
?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>UserAgent</title>
</head>
<body>
    <h1>Test UserAgent</h1>
    <p>UserAgent: <?php echo $useragent->useragent; ?></p>
    <p>Platform Type: <?php echo $useragent->platform['type'] ?>
    <p>Device: <img src="<?php echo $useragent->device['image'] ?>"/><?php echo $useragent->device['title'] ?>(Brand: <?php echo $useragent->device['brand'] ?>, Model: <?php echo $useragent->device['model'] ?>) </p>
    <p>OS: <img src="<?php echo $useragent->os['image'] ?>"/><?php echo $useragent->os['title'] ?> (Name = <?php echo $useragent->os['name'] ?>, Version = <?php echo $useragent->os['version'] ?>)</p>
    <p>Browser: <img src="<?php echo $useragent->browser['image'] ?>"/><?php echo $useragent->browser['title'] ?> (Name = <?php echo $useragent->browser['name'] ?>, Version = <?php echo $useragent->browser['version'] ?>)</p>

</body>
</html>

##待办事项

  • 将像 useragent.js 这样的 RegExps 从 PHP 文件中移出

##许可证