Page 1 sur 1

Script PHP pour determiner le navigateur internet

Posté : mer. 30 sept. 2020 08:54
par factor23
Voila :

Code : Tout sélectionner

[code]<?php
$chain = " " . $_SERVER['HTTP_USER_AGENT'];
$posfirefox = strpos($chain,"Firefox");
$posopera = strpos($chain,"Opera");
$postrident = strpos($chain,"Trident");
$posopr = strpos($chain,"OPR");
$poschrome = strpos($chain,"Chrome") && !$posopr;
$possafari = strpos($chain,"Safari") && !$poschrome && !$posopr;

If ($posfirefox > 0) {
   $navig = "Firefox";
   $ver= substr($chain,69,4);}
   elseif ($posopera > 0) {
   $navig="Opera";
   $ver=substr($chain,60,5);}
   elseif ($postrident > 0) {
   $navig = " IE";
   $ver = substr($chain,53,4);}
   elseif ($poschrome > 0) {
   $navig = "Chrome";
   $ver=substr($chain,83,13);}
   elseif ($possafari > 0) {
   $navig="Safari";
   $ver=substr($chain,99,8);}
   elseif ($posopr > 0) {
   $navig = "Opera";
   $ver = substr($chain,115,13);}
echo $navig . " ". $ver
?>
[/code]