Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,8 @@ PHP NEWS
(Weilin Du)
. getenv() and putenv() now raises a ValueError when the first argument
contains null bytes. (Weilin Du)
. Improved explode() ValueError message when $separator is empty; suggests
str_split() or mb_str_split(). (diegoasales)

- Streams:
. Added so_keepalive, tcp_keepidle, tcp_keepintvl and tcp_keepcnt stream
Expand Down
4 changes: 4 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,10 @@ PHP 8.6 UPGRADE NOTES
when not null, and on failure, gives the error code (one of the EAI_*
constants).

- Standard:
. explode() ValueError message when $separator is empty now suggests
str_split() or mb_str_split().
Comment thread
TimWolla marked this conversation as resolved.
Outdated

========================================
6. New Functions
========================================
Expand Down
2 changes: 1 addition & 1 deletion ext/standard/string.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,7 +914,7 @@ PHP_FUNCTION(explode)
ZEND_PARSE_PARAMETERS_END();

if (ZSTR_LEN(delim) == 0) {
zend_argument_must_not_be_empty_error(1);
zend_argument_value_error(1, "must not be empty. Use str_split() or mb_str_split() to split a string into characters");
Comment thread
TimWolla marked this conversation as resolved.
Outdated
RETURN_THROWS();
}

Expand Down
8 changes: 4 additions & 4 deletions ext/standard/tests/strings/explode.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ array (
4 => 'd',
)
d6bee42a771449205344c0938ad4f035
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
array(1) {
[0]=>
string(0) ""
Expand All @@ -79,7 +79,7 @@ array(1) {
[0]=>
string(0) ""
}
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
array(1) {
[0]=>
string(3) "acb"
Expand Down
24 changes: 12 additions & 12 deletions ext/standard/tests/strings/explode1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ var_dump( explode("b", $obj) );
--EXPECT--
*** Testing explode() for basic operations ***
-- Iteration 1 --
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
-- Iteration 2 --
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
-- Iteration 3 --
array(1) {
[0]=>
Expand Down Expand Up @@ -201,10 +201,10 @@ array(2) {
string(56) "234NULL23abcd00000TRUEFALSE-11.234444true-11.24%PHP%ZEND"
}
-- Iteration 7 --
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
explode(): Argument #1 ($separator) must not be empty. Use str_split() or mb_str_split() to split a string into characters
-- Iteration 8 --
array(2) {
[0]=>
Expand Down
Loading