Skip to content

Commit c246c9e

Browse files
committed
More strings
1 parent 00dafaf commit c246c9e

8 files changed

+469
-1190
lines changed

‎ext/standard/tests/strings/implode_variation.phpt

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@ $pieces = array(
2727
"PHP",
2828
"",
2929
" ",
30-
"string\x00with\x00...\0"
3130
);
3231
$glues = array(
3332
"TRUE",
3433
array("key1", "key2"),
3534
"",
3635
" ",
37-
"string\x00between",
3836
-0,
3937
'\0'
4038
);
@@ -175,23 +173,17 @@ array(1) {
175173

176174
*** Testing implode() with variations of glue ***
177175
-- Iteration 1 --
178-
string(59) "2TRUE0TRUE-639TRUE1TRUEPHPTRUETRUETRUE TRUEstring%0with%0...%0"
176+
string(30) "2TRUE0TRUE-639TRUEPHPTRUETRUE "
179177
-- Iteration 2 --
180-
string(35) "2101-639111PHP111 1string%0with%0...%0"
178+
implode(): Argument #1 ($separator) must be of type string, array given
181179
-- Iteration 3 --
182-
string(27) "20-6391PHP string%0with%0...%0"
180+
string(10) "20-639PHP "
183181
-- Iteration 4 --
184-
implode(): Argument #1 ($separator) must be of type string, array given
182+
string(15) "2 0 -639 PHP "
185183
-- Iteration 5 --
186-
string(27) "20-6391PHP string%0with%0...%0"
184+
string(15) "2000-6390PHP00 "
187185
-- Iteration 6 --
188-
string(35) "2 0 -639 1 PHP string%0with%0...%0"
189-
-- Iteration 7 --
190-
string(139) "2string%0between0string%0between-639string%0between1string%0betweenPHPstring%0betweenstring%0betweenstring%0between string%0betweenstring%0with%0...%0"
191-
-- Iteration 8 --
192-
string(35) "2000-639010PHP000 0string%0with%0...%0"
193-
-- Iteration 9 --
194-
string(43) "2\00\0-639\01\0PHP\0\0\0 \0string%0with%0...%0"
186+
string(20) "2\00\0-639\0PHP\0\0 "
195187

196188
*** Testing implode() on empty string ***
197189
implode(): If argument #1 ($separator) is of type string, argument #2 ($array) must be of type array, null given
@@ -204,9 +196,9 @@ Warning: Array to string conversion in %s on line %d
204196
string(27) "ArrayTESTArrayTESTPHPTEST50"
205197
implode(): Argument #1 ($separator) must be of type string, array given
206198

207-
Warning: Array to string conversion in %s
199+
Warning: Array to string conversion in %s on line %d
208200

209-
Warning: Array to string conversion in %s
201+
Warning: Array to string conversion in %s on line %d
210202
string(18) "Array2Array2PHP250"
211203

212204
*** Testing implode() on objects ***
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
--TEST--
2+
Test implode() function with strings with null bytes
3+
--FILE--
4+
<?php
5+
6+
$pieces = [
7+
'PHP',
8+
'is',
9+
'great',
10+
];
11+
12+
$glues = [
13+
"\0",
14+
"string\x00between",
15+
];
16+
17+
foreach ($glues as $glue) {
18+
var_dump(implode($glue, $pieces));
19+
}
20+
21+
?>
22+
--EXPECTF--
23+
string(12) "PHP%0is%0great"
24+
string(38) "PHPstring%0betweenisstring%0betweengreat"

0 commit comments

Comments
 (0)