php5.3 Prompt Function ereg of is deprecated Error Problem Solution

  • 2021-08-03 09:27:02
  • OfStack

In this paper, the solution of php 5.3 prompt Function ereg () is deprecated Error problem is described as an example. Share it for your reference. The specific implementation method is as follows:

1. Issues:

PHP 5.3 ereg () can't be used normally, suggesting that "Function ereg () is deprecated Error" is because its long ereg function has been upgraded, and it needs to be regulated by using//like preg_match. Of course, it is also the rhythm that php5.3 abolishes ereg.

PHP 5.3 ereg () cannot be used normally, indicating "Function ereg () is deprecated Error".
The root of the problem is that there are two regular representations in php, one is posix and the other is perl. php6 intends to abolish the regular representation of posix, so it later added preg_match. The solution to this problem is simple. Add a filter message symbol before ereg: change ereg () to @ ereg (). This shields the prompt information, but the fundamental problem remains unsolved. php was used normally before version 5.2, and preg_match will be used instead of ereg after version 5.3. So it needs to be like this.

Original: ereg ("^ [0-9] * $", $page) becomes: preg_match ("/^ [0-9] * $/", $page)

Special reminder: The obvious difference between posix and perl is whether to add slashes, so compared with ereg, the latter adds two "/" symbols before and after regularization, which cannot be lacking.

For example:

Before change:

function inject_check($sql_str) {
 $sql_str = strtolower($sql_str);
 return eregi('fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile', $sql_str); // Filter
}

2. Solution:
Find the file location where the code is located:
function inject_check($sql_str) { 
 $sql_str = strtolower($sql_str);
 return preg_match('/fopen|post|eval|select|insert|and|or|update|delete|'|/*|*|../|./|union|into|load_file|outfile/', $sql_str); // Filter
}


Note: 1 must add '/' at the beginning and end. Reference to this paragraph: https://www.ofstack.com/article/38857. htm

Add: This problem will not occur before php 5.2.

I hope this article is helpful to everyone's PHP programming.


Related articles: