‘eregi’ is deprecated errors

The other weekend I was setting up Plogger for my daughter to share her photos. She’s been really getting in to photography and I think she’s really getting good at it. If you’re interested (and she starts uploading stuff and takes down the pics I posted) you can check it out here: lexie.fourthwoods.com.


Anyway, apparently I’m running a newer PHP than Plogger was originally written for because I got a bunch of errors along the lines of:

Deprecated: Function eregi() is deprecated in blah....

It seems thewhole class of functions have been deprecated in PHP 5.3.0. Fortunately there is an easy fix. For instance:

eregi("NIKON", $make)

should be changed to:

preg_match('/NIKON/i', $make)

Note the regular expression is wrapped in ‘/’ characters which denote the pattern to search. after the last ‘/’ is the ‘i’ modifier flag which indicates case insensitive which is what eregi does.


Other functions that can be replaced similarly are:

ereg()          // replace with preg_match()
ereg_replace()  // replace with preg_replace()
eregi()         // replace with preg_match() with the 'i'
                // modifier
eregi_replace() // replace with preg_replace() with the
                // 'i' modifier

Related Posts

Leave a Reply