Function eregi is deprecated of solution

  • 2020-06-19 09:51:12
  • OfStack

After php was upgraded to php5.3, it was often found that some programs would report error messages of Function eregi() is deprecated. What's the reason?
This is because the eregi() function is no longer supported in php5.3 and is replaced by the preg_match() function.
The solution: replace the eregi() function with the preg_match() function.
if(eregi('^test',$file))
I can substitute
if(preg_match('/^test/i',$file))

-- -- -
After PHP 5.3.0, regex PCRE and POSIX Regex will not be used. .
So the following is an Function (POSIX) that is not built for use, a list of Function (PCRE) that is created for use, PHP:
Differences from POSIX regex
* POSIX - PCRE
* ereg_replace () - > preg_replace ()
* ereg () - > preg_match ()
* eregi_replace () - > preg_replace ()
* eregi () - > preg_match ()
* split () - > preg_split ()
* spliti () - > preg_split ()
* sql_regcase() → No equivalent
* split of regex is required and can be replaced by preg_split()
* regex is not required, but explode() can be used instead of regex ().

Related articles: