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

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

藏色散人
Release: 2023-04-07 21:56:02
forward
2709 people have browsed it

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
Copy after login

* 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!

Related labels:
php
source:cnblogs.com
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