PHP Function ereg () is deprecated workaround

Source: Internet
Author: User
Tags deprecated ereg posix

PHP 5.3 ereg () does not work properly, prompting "Function ereg () is deprecated Error". The problem is that there are two regular representations in PHP, one is POSIX, and the other is a regular representation of PERL,PHP6 's intention to abolish POSIX, so it adds a preg_match later. The solution to this problem is simple, add a filter cue message symbol before Ereg: Turn ereg () into @ereg (). This blocked the hint message, but the fundamental problem is not resolved, PHP in the 5.2 version before the use of normal ereg, after 5.3, it is necessary to use Preg_match to replace Ereg. So the need to become this, the original:
Ereg ("^[0-9]*$", $page)
Become:
Preg_match ("/^[0-9]*$/", $page)

http://www.jinyuanbao.cn
Special reminder: The obvious difference between POSIX and Perl is whether or not to add slashes, so compared with Ereg, the latter added two "/" symbols to the regular before and after, not missing.
Tips: This issue does not occur in versions prior to php5.2.

PHP Function ereg () is deprecated workaround

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.