Created
April 7, 2026 23:18
-
-
Save estefanionsantos/80830db8e00590bb4a1371d2b8041e7f to your computer and use it in GitHub Desktop.
Preparing the Configuration Data
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| use Rubricate\Agent\UserAgent; | |
| // 1. Instantiate the class passing the configurations | |
| $ua = new UserAgent($config); | |
| // 2. Checking the device type | |
| if ($ua->isMobile()) { | |
| echo "You are using a mobile device: " . $ua->getMobile(); | |
| } elseif ($ua->isRobot()) { | |
| echo "Hello, robot: " . $ua->getRobot(); | |
| } else { | |
| echo "You are on a Desktop."; | |
| } | |
| echo "<br>"; | |
| // 3. Obtaining specific browser information | |
| if ($ua->isBrowser()) { | |
| echo "Browser: " . $ua->getBrowser() . " (Version: " . $ua->getVersion() . ")"; | |
| } | |
| echo "<br>"; // 4. Checking the Platform (OS) | |
| echo "Operating System: " . $ua->getPlatform(); | |
| echo "<br>"; | |
| / 5. Accepted Languages | |
| echo "Preferred Languages: " . implode(', ', $ua->getLanguages()); | |
| / 6. Specific Boolean Check | |
| if ($ua->acceptLang('pt-br')) { | |
| echo "The user accepts Brazilian Portuguese."; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment