Function eregi is deprecated (workaround) _php tips

Source: Internet
Author: User
Tags deprecated posix
After PHP has been upgraded to php5.3, the procedure that is used frequently discovers that a function eregi () is deprecated error message. What's the reason?
This is because the eregi () function is no longer supported in php5.3, and the Preg_match () function is used 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))

————-
The regex after PHP 5.3.0, which would like to use the PCRE specification, POSIX regex does not recommend the use of the (System regex, avoid too many rules?).
So the following is a list of proposed function (POSIX) that is not recommended for use (PCRE), which is detailed: PHP:
Differences from POSIX Regex
* Posix→pcre
* Ereg_replace () →preg_replace ()
* Ereg () →preg_match ()
* Eregi_replace () →preg_replace ()
* EREGI () →preg_match ()
* Split () →preg_split ()
* Spliti () →preg_split ()
* Sql_regcase () →no equivalent
* Need a Regex split, use Preg_split () instead
* Do not need a regex, as long as you want to quickly split a fixed string, you can use explode () instead. (Faster than a regex is needed)

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.