77> ** Browserizr** is tiny library, that detects your browser and platform,
88> with testing ` $_SERVER['HTTP_USER_AGENT'] ` .
99
10- _ that is PHP port of JavaScript library [ WezomAgency/Browserizr] ( https://github.com/WezomAgency/browserizr )
10+ _ that is PHP port of the JavaScript library [ WezomAgency/Browserizr] ( https://github.com/WezomAgency/browserizr )
1111with several limitations..._
1212
1313---
@@ -18,7 +18,88 @@ with several limitations..._
1818composer require wezom-agency/browserizr
1919```
2020
21- ## Usage
21+ ---
22+
23+ ## API
24+
25+ ### List of built-in tests
26+
27+ 1 . ` Browserizr::$is_android `
28+ 1 . ` Browserizr::$is_android3 `
29+ 1 . ` Browserizr::$is_android4 `
30+ 1 . ` Browserizr::$is_android5 `
31+ 1 . ` Browserizr::$is_android6 `
32+ 1 . ` Browserizr::$is_android7 `
33+ 1 . ` Browserizr::$is_android8 `
34+ 1 . ` Browserizr::$is_blackberry `
35+ 1 . ` Browserizr::$is_blackberry10 `
36+ 1 . ` Browserizr::$is_edge `
37+ 1 . ` Browserizr::$is_edge_android `
38+ 1 . ` Browserizr::$is_edge_ios `
39+ 1 . ` Browserizr::$is_ie `
40+ 1 . ` Browserizr::$is_ie8 `
41+ 1 . ` Browserizr::$is_ie9 `
42+ 1 . ` Browserizr::$is_ie10 `
43+ 1 . ` Browserizr::$is_ie11 `
44+ 1 . ` Browserizr::$is_ipad `
45+ 1 . ` Browserizr::$is_ipod `
46+ 1 . ` Browserizr::$is_iphone `
47+ 1 . ` Browserizr::$is_windows_phone `
48+ 1 . ` Browserizr::$is_moz `
49+ 1 . ` Browserizr::$is_opera `
50+ 1 . ` Browserizr::$is_safari `
51+ 1 . ` Browserizr::$is_chrome `
52+ 1 . ` Browserizr::$is_mobile `
53+ 1 . ` Browserizr::$is_desktop `
54+
55+ _ Usage examples:_
56+
57+ ``` php
58+ <?php
59+
60+ use WezomAgency\Browserizr;
61+
62+ ?>
63+ <?php if (Browserizr::$is_chrome) { ?>
64+ <div class =" alert" >Chrome is here, baby!!!</div >
65+ <?php } ?>
66+
67+ ```
68+
69+ ---
70+
71+ ### Static methods
72+
73+ #### ` add_classes($tests, $css_prefix = "") `
74+
75+ > Create string with CSS classes
76+
77+ _ Parameters:_
78+
79+ Name | Data type | Default value | Description
80+ --- | --- | --- | ---
81+ ` $tests ` | ` string[] ` | | array of wanted tests
82+ ` $css_prefix ` | ` string ` | ` "" ` | custom prefix for CSS class name
83+
84+ _ Usage examples:_
85+
86+ ``` php
87+ <?php
88+
89+ use WezomAgency\Browserizr;
90+
91+ ?>
92+ <!DOCTYPE html>
93+ <html class =" <?= Browserizr::add_classes(['mobile', 'desktop']); ?>" >
94+ <head >...</head >
95+ <body >...</body >
96+ </html >
97+
98+ <!-- render output -->
99+ <html class =" is-mobile is-not-desktop" ><!-- if mobile device -->
100+ <html class =" is-not-mobile is-desktop" ><!-- if desktop -->
101+
102+ ```
22103
23104``` php
24105<?php
@@ -32,4 +113,38 @@ use WezomAgency\Browserizr;
32113 <body >...</body >
33114</html >
34115
116+ <!-- render output -->
117+ <html class =" browserizr-is-mobile browserizr-is-not-desktop" ><!-- if mobile device -->
118+ <html class =" browserizr-is-not-mobile browserizr-is-desktop" ><!-- if desktop -->
119+
120+ ```
121+
122+ #### ` detect($custom_user_agent = null) `
123+
124+ > re-checkout all detections
125+
126+ _ Parameters:_
127+
128+ Name | Data type | Default value | Description
129+ --- | --- | --- | ---
130+ ` $custom_user_agent ` | ` string ` | ` $_SERVER['HTTP_USER_AGENT'] ` | string for tests
131+
132+ _ Usage examples:_
133+
134+ ``` php
135+ <?php
136+
137+ use WezomAgency\Browserizr;
138+
139+ Browserizr::detect('my_user_agent')
140+
141+ ?>
142+ <?php if (Browserizr::$is_edge_ios) { ?>
143+ <div class =" alert" >Edge is here, baby! Yes, on iOS!</div >
144+ <?php } ?>
145+
35146```
147+
148+ ---
149+
150+
0 commit comments