承接 wezom-agency/browserizr 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

wezom-agency/browserizr

最新稳定版本:3.0.2

Composer 安装命令:

composer require wezom-agency/browserizr

包简介

Browserizr is tiny library, that detects your browser

README 文档

README

license composer npm WezomAgency

Browserizr is tiny library, that detects your browser
with testing $_SERVER['HTTP_USER_AGENT'].

that is PHP port of the JavaScript library WezomAgency/Browserizr
with several limitations...

Install

composer require wezom-agency/browserizr

Prev versions

please read:

API

List of built-in tests

  1. Browserizr::detect()->isAndroid()
  2. Browserizr::detect()->isAndroid3()
  3. Browserizr::detect()->isAndroid4()
  4. Browserizr::detect()->isAndroid5()
  5. Browserizr::detect()->isAndroid6()
  6. Browserizr::detect()->isAndroid7()
  7. Browserizr::detect()->isAndroid8()
  8. Browserizr::detect()->isBlackberry()
  9. Browserizr::detect()->isBlackberry10()
  10. Browserizr::detect()->isEdge()
  11. Browserizr::detect()->isEdgeAndroid()
  12. Browserizr::detect()->isEdgeIOS()
  13. Browserizr::detect()->isIE()
  14. Browserizr::detect()->isIE8()
  15. Browserizr::detect()->isIE9()
  16. Browserizr::detect()->isIE10()
  17. Browserizr::detect()->isIE11()
  18. Browserizr::detect()->isIPad()
  19. Browserizr::detect()->isIPod()
  20. Browserizr::detect()->isIPhone()
  21. Browserizr::detect()->isWindowsPhone()
  22. Browserizr::detect()->isMoz()
  23. Browserizr::detect()->isOpera()
  24. Browserizr::detect()->isSafari()
  25. Browserizr::detect()->isChrome()
  26. Browserizr::detect()->isMobile()
  27. Browserizr::detect()->isDesktop()

Usage examples:

<?php

use WezomAgency\Browserizr;

?>
<?php if (Browserizr::detect()->isChrome()) { ?>
    <div class="alert">Chrome is here, baby!!!</div>
<?php } ?>

Generate css classes

Browserizr::detect()->cssClasses($tests, $cssPrefix = "", $toString = true): array|string

Create string with CSS classes

Parameters:

Name Data type Default value Description
$tests string[] array of wanted tests, each name - test name without is prefix
$cssPrefix string "" custom prefix for CSS class name
$toString bool true implode resulted array and return as string;

Usage examples:

<?php

use WezomAgency\Browserizr;

?>
<!DOCTYPE html>
<html class="<?= Browserizr::detect()->cssClasses(['Mobile', 'Desktop']); ?>">
    <head>...</head>
    <body>...</body>
</html>

<!-- render output -->
<html class="is-mobile is-not-desktop"><!-- if mobile device -->
<html class="is-not-mobile is-desktop"><!-- if desktop -->
<?php

use WezomAgency\Browserizr;

?>
<!DOCTYPE html>
<html class="<?= Browserizr::detect()->cssClasses(['Mobile', 'Desktop'], 'browserizr-'); ?>">
    <head>...</head>
    <body>...</body>
</html>

<!-- render output -->
<html class="browserizr-is-mobile browserizr-is-not-desktop"><!-- if mobile device -->
<html class="browserizr-is-not-mobile browserizr-is-desktop"><!-- if desktop -->
<?php

use WezomAgency\Browserizr;

$myCssClasses = Browserizr::detect()->cssClasses(['Mobile', 'Desktop'], '', false);
// ... work with array, e.g. array_push() or array_combine() or whatever you want

?>

Set custom UserAgent

by default Browserizr use $_SERVER['HTTP_USER_AGENT']
you can set own string for UserAgent.

Note
if you needed to change agent - you must do it before use the Browserizr tests

<?php

use WezomAgency\Browserizr;

Browserizr::detect()->setUserAgent('my own UserAgent string');

// then can test your browser correctly
var_export(Browserizr::detect()->isWindowsPhone());

统计信息

  • 总下载量: 5.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-10-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固