Bonjour !
Je souhaite pour mon site détecter le navigateur client et sa version grâce à PHP.
Mes connaissances étant un peu limitées dans ce domaine, j'ai trouvé après quelques recherches ceci :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php 
		function browser_info($agent=null) {
 $known = array('msie', 'firefox', 'safari', 'webkit', 'opera', 'netscape',
 'konqueror', 'gecko');
 $agent = strtolower($agent? $agent: $_SERVER['HTTP_USER_AGENT']);
 $pattern = '#(?'. join('|', $known) .
 ')[/ ]+(?[0–9]+(?:\.[0–9]+)?)#';
 
 if (!preg_match_all($pattern, $agent, $matches)) return array();
 $i = count($matches['browser'])-1;
 return array($matches['browser'][$i], $matches['version'][$i]);
}
 
$res = browser_info();
print_r($res);
?>
Cela me retourne le message d'erreur :
Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (? or (?- at offset 5 in C:\Users\Julien\Work\EasyPHP-5.3.9\www\Portfolio\OSdetect.php on line 9
Array ( )
Quelqu'un saurait m'expliquer le problème ? Voire même m'expliquer le fonctionnement de ce script ? Merci d'avance !