I'm using a script to detect the browser and its version that is referenced multiple times on the get_browser page on php.net.
The file containing the script is saved as UTF-8 and actually it works fine´:
// relevant parts only where $ub stores the browser name like "Safari"
$userAgent = $_SERVER['HTTP_USER_AGENT'];
$known = array('Version', $ub, 'other');
$pattern = '#(?<browser>' . join('|', $known) . ')[/ ]+(?<version>[0-9.|a-zA-Z.]*)#';
preg_match_all($pattern, $userAgent, $matches);
Now we're running a site on a server that uses PHP 5.1.6. Unfortunately it breaks the regex and displays this warning:
PHP Warning: preg_match_all() [function.preg-match-all]: Compilation failed: unrecognized character after (?< at offset 3 in /file.php on line 48
How must the pattern be updated to work properly with PHP 5.1.6?