PHP Function eregi () is deprecated solution

Source: Internet
Author: User
Tags deprecated ereg versions

First of all, the difference between ereg () and eregi ():

Ereg () string contrast matching function, which distinguishes string capitalization;

Eregi () string contrast matching functions, which do not distinguish between string capitalization.

These two functions are often used in PHP regular, but since php5.3 later versions no longer support this function, using this function will report: Function eregi () is deprecated error. Use the Preg_match () function if you are using regular in php5.3 and later versions.

This is because the eregi () function is no longer supported by php5.3, and the Preg_match () function is recommended instead.

The workaround is to replace the eregi () function with the Preg_match () function.

if (eregi (' ^test ', $file))

can be replaced by

if (Preg_match ('/^test/i ', $file))

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.