Home > Article > Backend Development > Some errors occurred after php was upgraded to 5.3, such as ereg(); ereg_replace(); function error, eregeg_replace_PHP tutorial
often occurs when running in php5.3 environment
Deprecated: Function ereg() is deprecated in... and Deprecated: Function ereg_replace() is deprecated in... These types of error messages.
The reason is: PHP5.3 or above does not support the ereg() function, but uses the preg_match() function; it does not support the ereg_replace() function, but uses the preg_replace() function.
Solution: Just change the unsupported function to a supported function.
For example
if(eregi('^('value', $value)
Changed to:
if(preg_match('/value/', $value)
🎜> Another example:
$string = ereg_replace(' value', ' ', trim($string));
Change to:
$string = preg_replace('{ value}', ' ', trim($string));
Solution to Deprecated: Assigning the return value of new by reference is deprecated in error
After version 5.3, the "=&" symbol is no longer allowed in programs. If the error Deprecated: Assigning the return value of new by reference is deprecated in appears on your website, don’t worry. First locate the file with the error and check whether “=&” is used in the program. You will find that “=” is used. &" symbol, the program runs normally after removing the '&' symbol.
Problem: Deprecated: Function set_magic_quotes_runtime() is deprecated in The reason for this prompt is that this feature (set_magic_quotes_runtime()) has been turned off after PHP5.3.
And this feature has been completely removed in PHP6.
You can comment or delete the wrong line, or add the @ symbol in front of set_magic_quotes_runtime()