explode() Forbids Empty Strings¶
explode() doesn’t work on empty strings, as delimiter (first argument). It used to be a warning and a returned value of false, it is now a Fatal error.
PHP code¶
<?php
explode('', 'abc');
?>
Before¶
PHP Warning: explode(): Empty delimiter
Warning: explode(): Empty delimiter
After¶
PHP Fatal error: Uncaught ValueError: explode(): Argument #1 ($separator) cannot be empty
Fatal error: Uncaught ValueError: explode(): Argument #1 ($separator) cannot be empty
PHP version change¶
This behavior changed in 8.0