我有这个功能,我得到这个错误Deprecated: Function eregi() is deprecated in...
。如果我更改eregi
为preg_match
我收到此错误Warning: preg_match() [function.preg-match]: Delimiter must not be alphanumeric or backslash in...
function getBrowser($userAgent) {
$browsers = array(
'Opera' => 'Opera',
'Mozilla Firefox'=> '(Firebird)|(Firefox)', // Use regular expressions as value to identify browser
'Galeon' => 'Galeon',
'Chrome'=>'Gecko',
'MyIE'=>'MyIE',
'Lynx' => 'Lynx',
'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)',
'Konqueror'=>'Konqueror',
'SearchBot' => '(nuhk)|(Googlebot)|(Yammybot)|(Openbot)|(Slurp/cat)|(msnbot)|(ia_archiver)',
'Internet Explorer 8' => '(MSIE 8\.[0-9]+)',
'Internet Explorer 7' => '(MSIE 7\.[0-9]+)',
'Internet Explorer 6' => '(MSIE 6\.[0-9]+)',
'Internet Explorer 5' => '(MSIE 5\.[0-9]+)',
'Internet Explorer 4' => '(MSIE 4\.[0-9]+)',
);
foreach($browsers as $browser=>$pattern) {
if(eregi($pattern, $userAgent)) {
return $browser;
}
}
return 'Unknown';
}
有想法该怎么解决这个吗。如果你们不介意的话,我也想对正在发生的事情做一个简单的解释,这样我就能理解
谢谢