How to solve the problem of Functionereg () isdeprecatedError that occurs at the beginning of php5.3-PHP source code

Source: Internet
Author: User
Function ereg () isdeprecatedError in php5.3

PHP 5.3 ereg () cannot be used normally. the prompt "Function ereg () is deprecated Error" is displayed ". The root cause is that there are two regular expression methods in php, one is posix and the other is perl. php6 intends to abolish the regular expression method of posix, so a preg_match is added later. The solution to this problem is simple. add a filter prompt symbol before ereg to convert ereg () to @ ereg (). In this way, the prompt information is blocked, but the root problem is still not solved. php uses ereg normally before version 5.2. after version 5.3, preg_match should be used to replace ereg. Therefore, you need to change it to the following: ereg ("^ [0-9] * $", $ page: preg_match ("/^ [0-9] * $/", $ page) Special note: The obvious difference between posix and perl is whether to add a slash. Therefore, compared with ereg, the latter adds two "/" symbols before and after the regular expression, which cannot be missing. Tips: This problem does not occur in php5.2 or earlier versions.

The above is the Function ereg () is deprecated Error solution that appears at php5.3. For more information, see The PHP Chinese website (www.php1.cn )!

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.