TottoBennington Posted July 31, 2012 Share Posted July 31, 2012 Can anyone help me with this error ? Deprecated: Function eregi() is deprecated in C:\wamp\www\phpDetectIE\index.php on line 18 <?php function ObtenerNavegador($user_agent) { $navegadores = array( 'Opera' => 'Opera', 'Mozilla Firefox'=> '(Firebird)|(Firefox)', 'Galeon' => 'Galeon', 'Mozilla'=>'Gecko', 'MyIE'=>'MyIE', 'Lynx' => 'Lynx', 'Netscape' => '(Mozilla/4\.75)|(Netscape6)|(Mozilla/4\.08)|(Mozilla/4\.5)|(Mozilla/4\.6)|(Mozilla/4\.79)', 'Konqueror'=>'Konqueror', '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($navegadores as $navegador=>$pattern){ if (eregi($pattern, $user_agent)) return $navegador; } return 'Desconocido'; } ?> <?php echo ObtenerNavegador($_SERVER['HTTP_USER_AGENT']) ?> Quote Link to comment https://forums.phpfreaks.com/topic/266519-deprecated-function-eregi-is-deprecated-line-18/ Share on other sites More sharing options...
cpd Posted July 31, 2012 Share Posted July 31, 2012 Its deprecated in the version of PHP your using... so you can't use it. Use preg_match instead. Quote Link to comment https://forums.phpfreaks.com/topic/266519-deprecated-function-eregi-is-deprecated-line-18/#findComment-1365831 Share on other sites More sharing options...
.josh Posted August 1, 2012 Share Posted August 1, 2012 Its deprecated in the version of PHP your using... so you can't use it. Use preg_match instead. deprecated doesn't mean you can't use it, it means it's advisable that you stop using it because it will eventually go away and not be supported in future versions of php. Quote Link to comment https://forums.phpfreaks.com/topic/266519-deprecated-function-eregi-is-deprecated-line-18/#findComment-1365860 Share on other sites More sharing options...
premiso Posted August 1, 2012 Share Posted August 1, 2012 if (preg_match("#{$pattern}#i", $user_agent)) Will fix your problem. Quote Link to comment https://forums.phpfreaks.com/topic/266519-deprecated-function-eregi-is-deprecated-line-18/#findComment-1365867 Share on other sites More sharing options...
cpd Posted August 1, 2012 Share Posted August 1, 2012 Its deprecated in the version of PHP your using... so you can't use it. Use preg_match instead. deprecated doesn't mean you can't use it, it means it's advisable that you stop using it because it will eventually go away and not be supported in future versions of php. Yes sorry, poor choice of wording. Quote Link to comment https://forums.phpfreaks.com/topic/266519-deprecated-function-eregi-is-deprecated-line-18/#findComment-1365942 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.