Function ereg() is deprecated

Created by: Administrator, Last modification: 02 Sep 2018 (11:27 UTC)

Thanks to Len - StackOverflow

You must use preg_match instead of ereg because the last one is deprecated.

Replacing it is not a big deal:

ereg("[][{}()*+?.\\^$|]", $_REQUEST['name'] )

will become:

preg_match( "/[][{}()*+?.\\^$|]/", $_REQUEST['name'] )

p.s. I had to modify more than one hundred files while I was porting my old project to PHP 5.3 to avoid manually modifying I've used following script to do it for me:

function replaceEregWithPregMatch($path) {
    $content = file_get_contents($path);
    $content = preg_replace('/ereg\(("|\')(.+)(\"|\'),/',
                            "preg_match('/$2/',",
                            $content);
    file_put_contents($path, $content);
}

I hope it helps.


Extra Notes ... StackOverflow

You can find the complete reference to PCRE syntax in PHP in the manual, as well as a list of differences between POSIX regex and PCRE to help converting the expression.