PHP Function split () is deprecated workaround

Source: Internet
Author: User
Tags deprecated posix

Original address: http://www.cnblogs.com/mfryf/archive/2012/05/31/2527307.html

When PHP is upgraded to 5.3, the program will report the error of Function split () is deprecated.
This is because of a variety of reasons (mainly about the cause of the regular, specifically, see later), split this function is not supported in the new version.
In PHP, the use of deprecated function will be an error, must be rid of. (The deprecated function in Java just gives a warning and can continue to use)
What's the change? Look at the first parameter, if the first argument is not a regular expression, split changes to explode, and if it is a regular expression, split changes to Preg_split.
Explode will be much faster than before, because the former has to consider the regular, explode do not consider the regular.
————-
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)

PHP Function split () is deprecated 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.