Function eregi is deprecated (workaround) _php tutorial

Source: Internet
Author: User
Tags posix
After PHP upgrade to php5.3, in the process of use often found that some programs will appear function eregi () is deprecated error message. What is the reason?
This is because the eregi () function is no longer supported in php5.3 and is replaced with the Preg_match () function.
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))

————-
PHP 5.3.0 after the regex, want to use the PCRE, POSIX regex is not recommended to use (the system of a regex, avoid too many?).
So the following is the non-recommended function (POSIX), with a list of proposed function (PCRE), see: 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
* Split with Regex, can be replaced by Preg_split ()
* Do not need a regex, as long as you want to quickly split the fixed string, can be replaced by explode (). (Speed is much faster than the need for a regex)

http://www.bkjia.com/PHPjc/327783.html www.bkjia.com true http://www.bkjia.com/PHPjc/327783.html techarticle After PHP upgrade to php5.3, in the process of use often found that some programs will appear function eregi () is deprecated error message. What is the reason? This is because the php5.3 no longer ...

  • 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.