Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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.

See Also

Error Messages

Extension

© 2023-2026, Damien Seguy - Exakat