2
Test str_split() function : usage variations - different integer values for 'split_length' with heredoc 'str'
5
if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only");
9
/* Prototype : array str_split(string $str [, int $split_length])
10
* Description: Convert a string to an array. If split_length is
11
specified, break the string down into chunks each
12
split_length characters long.
13
* Source code: ext/standard/string.c
14
* Alias to functions: none
18
* passing different integer values for 'split_length' and heredoc string as 'str' argument to str_split()
21
echo "*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' ***\n";
22
//Initialise variables
24
string with 123,escape char \t.
27
//different values for 'split_length'
31
-123, //negative integer
33
0x1A, //hexadecimal number
34
2147483647, //max positive integer number
35
2147483648, //max positive integer+1
36
-2147483648, //min negative integer
39
//loop through each element of $values for 'split_length'
40
for($count = 0; $count < count($values); $count++) {
41
echo "-- Iteration ".($count + 1)." --\n";
42
var_dump( str_split($str, $values[$count]) );
47
*** Testing str_split() : different intger values for 'split_length' with heredoc 'str' ***
50
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
117
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d
122
string(30) "string with 123,escape char ."
127
string(26) "string with 123,escape cha"
134
string(30) "string with 123,escape char ."
139
string(30) "string with 123,escape char ."
143
Warning: str_split(): The length of each segment must be greater than zero in %s on line %d