Get the App
SLTechnology News&Howtos  ›  Development  › 

How to solve the problem of php5.3 prompt Function ereg () is deprecated Error

Shulou Source: shulou.com Published: 2022-06-03 16:33:11 09月20日 Update

This article mainly introduces how to solve the problem of php5.3 prompt Function ereg () is deprecated Error, which is very detailed and has certain reference value. Friends who are interested must finish it!

1. Question:

PHP 5.3ereg () does not work properly. The hint "Function ereg () is deprecated Error" is because its long ereg function is upgraded, which requires rules like preg_match to use / /. Of course, it is also the rhythm that php5.3 abolishes ereg.

PHP 5.3ereg () does not work properly, prompting "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 that perl,php6 intends to abolish the regular representation of posix, so it later added a preg_match. The solution to this problem is simple: add a filter prompt symbol before ereg: change ereg () to @ ereg (). This shields the prompts, but the fundamental problem is still unsolved. Before version 5.2 of php, ereg was used normally. After 5.3, preg_match will be used instead of ereg. So it needs to be like this.

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

Special reminder: the obvious difference between posix and perl is whether or not to add a slash, so compared with ereg, the latter adds two "/" symbols before and after the regularization, which is indispensable.

For example:

Before the 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: be sure to add the beginning and end of'/'.

The above is all the content of the article "how to solve the problem of php5.3 prompt Function ereg () is deprecated Error". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!

Tags: Questions hints methods rules information content symbols articles obvious two code value location interests functions methods guys buddies that is the beginning Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Shulou Technology Apple NVidia Docker