About PHP Error: Deprecated:function ereg_replace () workaround

Source: Internet
Author: User

If you often use PHP open source program, after upgrading the PHP environment, must have encountered, Deprecated:function ereg_replace () error message

In the php5.3 version, in order to make programming more concise, discarded the ereg_replace regular function, but some early development of the PHP program, this function is often used, the following I have two ways to solve:

1. Replace the PHP version to php5.0, continue to use the previous version of the PHP environment, but this method is a bit less objective, if you are the purchase of virtual host, you can not replace PHP version 2. Modify the configuration file of the PHP environment, that is, modify the php.ini file:to find; Extension=php_mbstring.dll changed to: Extension=php_mbstring.dllfound; mbstring.func_overload = 0 modified to: mbstring.func_overload = 7This will continue to work, but modifying the php.ini file is as restrictive as the first method, and not all PHP runtime environments you have the right to modify 3. Using the latest regular function preg_replace, slightly different in regular substitution, such as: Ereg_replace ("[/\]{1 ,} ", '/', dirname (__file__)) modified should be: Preg_replace ("/[/\]{1,}/", '/', dirname (__file__)) in phpv5.3, PHP recommends the 3rd method, Because Preg_replace is much more efficient than ereg_replace.

About PHP Error: Deprecated:function ereg_replace () 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.