split() is a very common PHP function. Here I am not going to discuss its usage. But I will give a super simple solution for the error “Deprecated: Function split() is deprecated“. This error is annoying, and will happen to everyone using
split() function. So, keep reading for the super easy solution.
Why We Are Getting This Error Suddenly?
preg_split(), which uses a Perl-compatible regular expression syntax, is often a faster alternative to split(). If you don’t require the power of regular expressions, it is faster to use explode(), which doesn’t incur the overhead of the regular expression engine.
And, apparently “split” is removed as of PHP 5.3.x, in the preparation for PHP 6.0.
This function has been DEPRECATED as of PHP 5.3.0. Relying on this feature is highly discouraged.
So, you are not getting this error suddenly, your server PHP must have been upgraded recently to minimum 5.3.x or higher, and
split() does not work with latest PHP.
Just replace all
explode() does almost the same, so no worry.
Yes, solution is that simple.
preg_split still works.
Whats My Story Here?
Remember AmarIP.com? The Find My IP site I made? The server block I am hosting that site upgraded PHP to latest version and started to get this weird error. But thing is split() is a very common function, been used thousand times. And I have no idea that its been deprecated starting from 5.3.0, so had to dig a bit. Got my answer, AmarIP.com is now running fine. So thought will share it to help others, who already having this issue, or will have soon.
split() in PHP
explode() in PHP
Leave a Reply