Skip to content
PHP Logo

What is the error message when using the deprecated split function in PHP?

The error message when using the deprecated split function in PHP is "Deprecated: Function split() is deprecated". This means that the split function is no longer supported in PHP and should not be used. To solve this issue, you should replace the split function with the preg_split function, which provides similar functionality for splitting strings based on a regular expression.

php
// Deprecated split function
$string = "Hello,World";
$parts = split(",", $string);
print_r($parts); // Deprecated: Function split() is deprecated

// Using preg_split function
$string = "Hello,World";
$parts = preg_split("/,/", $string);
print_r($parts); // Array ( [0] => Hello [1] => World )