mhmmdq/useragent 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mhmmdq/useragent

最新稳定版本:1.0.0

Composer 安装命令:

composer require mhmmdq/useragent

包简介

A small package to identify the user's browser

README 文档

README

This package extracts $_SERVER['HTTP_USER_AGENT'] details of the client browser and provides the details to you as an array.

Installation

Installed by Composer

$ composer require mhmmdq\useragent

How to use

To use the package, first add the Autoloder Composer file to the software and then call the class

<?php

require __DIR__ . '/vendor/autoload.php';

use Mhmmdq\Useragent\UserAgent;

$useragent = UserAgent::analyze();

var_dump($useragent);

The output provides you with user information that has the following information

useragent useragent received from the client browser

browser An array containing the name and version of the client browser

platform Client platform

language Client browser language derived from $_SERVER['HTTP_ACCEPT_LANGUAGE'] analysis

is_mobile Check whether the client is mobile or not (The output of this value is true or false)

If you need to check different user agents, you can pass them to the analysis method
$useragent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36';
var_dump(UserAgent::analyze($useragent));

Check if the client is mobile or not

You can use the following method to do this

UserAgent::is_mobile();
Example
if(UserAgent::is_mobile()) {
    header('location: https://m.example.com');
}

Get the default browser language

The default language of the client browser is received using $_SERVER['HTTP_ACCEPT_LANGUAGE'] and after checking the output is provided as a string

UserAgent::lang();

统计信息

  • 总下载量: 43
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 8
  • 点击次数: 5
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 8
  • Watchers: 4
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2021-06-12