Home >Backend Development >PHP Tutorial >Some errors occurred after php was upgraded to 53+, such as ereg; ereg_replace; function error

Some errors occurred after php was upgraded to 53+, such as ereg; ereg_replace; function error

WBOY
WBOYOriginal
2016-07-29 09:11:03997browse

When running in the php5.3 environment, error messages such as

Deprecated: Function ereg() is deprecated in... and Deprecated: Function ereg_replace() is deprecated in... often appear.
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: Change the unsupported function to a supported function.
 
For example
if(eregi('^('value', $value)
Change to:
if (preg_match('/value/', $value)

Another example:
$string = ereg_replace(' value' , ' ', trim($string));
  Change to:
  $string = preg_replace('{ value}', ' ', trim($string));
 
Solve Deprecated: Assigning the return value of new by reference is deprecated in error

Because our current php is 5.3, you can use "=" directly in php5.3, but before, because of the local testing, the php environment below 5.3 used the "=&" symbol .

After version 5.3, the "=&" symbol is no longer allowed in the program. If your website has a Deprecated: Assigning the return value of new by reference is deprecated in error, don't worry, locate the wrong file first. , check whether "=&" is used in the program, and find that the "=&" symbol is used. After removing the '&' symbol, the program runs normally.

Problem: Deprecated: Function set_magic_quotes_runtime() is deprecated in
causing this. The reason for the 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 it in front of set_magic_quotes_runtime(). @symbol

The above has introduced some errors that occurred after PHP was upgraded to 53+, such as the error reported by the ereg; ereg_replace; function, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:WeChat app paymentNext article:WeChat app payment