Jump to content


Photo

Deprecated: Function eregi() is deprecated (Line 18)


  • Please log in to reply
4 replies to this topic

#1 TottoBennington

TottoBennington

    Member

  • Members
  • PipPip
  • 16 posts

Posted 31 July 2012 - 04:31 PM

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']) ?>


#2 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 733 posts
  • LocationLondon, UK

Posted 31 July 2012 - 04:37 PM

Its deprecated in the version of PHP your using... so you can't use it. Use preg_match instead.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."

#3 .josh

.josh

    Grumpy Old Man

  • Administrators
  • 13,827 posts
  • LocationWhere You Live.

Posted 31 July 2012 - 08:42 PM

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. 


Posted Image
Did I help you? Feeling generous? Donate to me! || Donate to phpfreaks!


#4 premiso

premiso

    Trollololol

  • Members
  • PipPipPip
  • 6,969 posts
  • LocationHairy Beaverville

Posted 31 July 2012 - 09:10 PM

if (preg_match("#{$pattern}#i", $user_agent))

Will fix your problem.
Did I assist you? Feeling like contributing to my gaming addiction?

Assist with my gaming addiction! | Free Flash Games | lxt Article Site

#5 cpd

cpd

    ¬_¬

  • Members
  • PipPipPip
  • 733 posts
  • LocationLondon, UK

Posted 01 August 2012 - 05:33 AM


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.
"Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it."

"One of my most productive days was throwing away 1000 lines of code."




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cheap Linux VPS from $5
SSD Storage, 30 day Guarantee
1 TB of BW, 100% Network Uptime

AlphaBit.com