php5.3 prompt function ereg () is deprecated error problem resolution _php tips

Source: Internet
Author: User
Tags deprecated ereg eval php programming posix

The example in this article describes the php5.3 hint function ereg () is deprecated error problem resolution. Share to everyone for your reference. The implementation methods are as follows:

First, the question:

PHP 5.3 Ereg () is not working properly, prompting "function ereg () is deprecated Error" because it has been upgraded for long ereg functions, and it needs to be used like the Preg_match//rules, Of course, is also php5.3 ereg to waste the rhythm of the.

PHP 5.3 Ereg () is not working properly, prompting "Function ereg () is deprecated Error".
The source of the problem is that there are two regular representations in PHP, one is POSIX, the other is PERL,PHP6 's intention to abolish POSIX regular representations, so we added a preg_match later. This problem solution is very simple, before ereg add a filter hint information symbol can be: the Ereg () into @ereg (). This shielding the hint information, but the fundamental problem is not resolved, PHP in the 5.2 version before ereg are used normally, after 5.3, it is necessary to use Preg_match to replace the ereg. So that's what needs to happen.

Originally: Ereg ("^[0-9]*$", $page) into: Preg_match ("/^[0-9]*$/", $page)

Special reminder: POSIX and Perl is the obvious difference is whether to add a slash, so compared with Ereg, the latter in the regular before and after the increase of two "/" symbol, can not be missing.

For example:

Before change:

Copy Code code as follows:
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); To filter
}

Second, the solution:
Locate the file location where the code resides:
Copy Code code as follows:
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); To filter
}


Note: Be sure to add '/' Start and end。 Reference to this paragraph: http://www.jb51.net/article/38857.htm

Add: This issue does not appear prior to php5.2.

I hope this article will help you with your PHP programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.