Function eregi is deprecated (solution)_PHP tutorial

WBOY
Release: 2016-07-21 15:04:18
Original
825 people have browsed it

After php was upgraded to php5.3, I often found that some programs would display the error message "Function eregi() is deprecated" during use. What is the reason?
This is because the eregi() function is no longer supported in php5.3 and the preg_match() function is used instead.
The solution is: replace the eregi() function with the preg_match() function.
if(eregi('^test',$file))
can be replaced with
if(preg_match('/^test/i',$file))

————-
For regex after PHP 5.3.0, I hope to use PCRE specifications. POSIX Regex is not recommended (unify Regex to avoid too many specifications?).
So the following is a list of functions (POSIX) that are deprecated, and functions (PCRE) that are recommended to be replaced. For details, 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
* For split that requires regex, you can use preg_split() instead.
* No need for regex, as long as you want to quickly split fixed words String, you can use explode() instead. (The speed will be much faster than requiring regex)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/327783.htmlTechArticleAfter php is upgraded to php5.3, it is often found that Function eregi( ) is deprecated error message. What is the reason? This is because php5.3 no longer...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!