Home  >  Article  >  Backend Development  >  How to solve the problem of php Function split() is deprecated

How to solve the problem of php Function split() is deprecated

藏色散人
藏色散人forward
2019-12-04 10:34:012590browse

After php is upgraded to 5.3, the program will report the error Function split() is deprecated.

This is because of various reasons (mainly about regularization, see below for details), the split function is not supported in the new version.

In PHP, if you use the deprecated function again, an error will be reported and must be changed. (The deprecated function in java only gives a warning and can still be used)

What should be changed? Look at the first parameter. If the first parameter is not a regular expression, split is changed to explode; if it is a regular expression, split is changed to preg_split.

explode will be much faster than before, because in the past, regularity had to be considered, and explode did not consider regularity.

For regex after PHP 5.3.0, I hope to use PCRE specifications. POSIX Regex is no longer recommended (unify Regex to avoid too many specifications?).

So the following is not recommended Function (POSIX) used, and a list of recommended functions (PCRE) to replace, 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

* regex split is required, preg_split() can be used instead

* Not required regex, as long as you want to quickly split a fixed string, you can use explode() instead. (The speed will be much faster than regex)

Recommended: "PHP Tutorial"

The above is the detailed content of How to solve the problem of php Function split() is deprecated. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:cnblogs.com. If there is any infringement, please contact admin@php.cn delete