Created
July 24, 2019 18:36
-
-
Save parzibyte/9e63af8df7663784ef91b43cb6fbaa92 to your computer and use it in GitHub Desktop.
This file contains 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 | |
/** | |
* Demostrar uso de librería uap-php | |
* | |
* https://parzibyte.me/blog | |
*/ | |
require_once "vendor/autoload.php"; | |
use UAParser\Parser; | |
# Podría venir de otro lado | |
$agenteDeUsuario = $_SERVER["HTTP_USER_AGENT"]; | |
$parseador = Parser::create(); | |
$resultado = $parseador->parse($agenteDeUsuario); | |
$familiaNavegador = $resultado->ua->family; // Chrome, Firefox, Safari, Edge | |
$navegador = $resultado->ua->toString(); | |
$dispositivo = $resultado->device->family; | |
$familiaSistema = $resultado->os->family; | |
$sistema = $resultado->os->toString(); | |
$completo = $resultado->toString(); | |
?> | |
<!DOCTYPE html> | |
<html lang="es"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
<title>Información de navegador</title> | |
</head> | |
<body> | |
<strong>Familia de navegador: </strong> <?php echo $familiaNavegador ?><br> | |
<strong>Navegador: </strong> <?php echo $navegador ?><br> | |
<strong>Dispositivo: </strong> <?php echo $dispositivo ?><br> | |
<strong>Familia de OS: </strong> <?php echo $familiaSistema ?><br> | |
<strong>Sistema operativo: </strong> <?php echo $sistema ?><br> | |
<strong>Información completa: </strong> <?php echo $completo ?><br> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment