summaryrefslogtreecommitdiff
path: root/ext/standard/tests/strings/chunk_split_variation11.phpt
blob: f20a4af22b41a2f94fcf1429258bcbdda2a04c73 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
--TEST--
Test chunk_split() function : usage variations - different strings for 'ending' with heredoc 'str'
--FILE--
<?php
/* Prototype  : string chunk_split(string $str [, int $chunklen [, string $ending]])
 * Description: Returns split line
 * Source code: ext/standard/string.c
 * Alias to functions: none
*/

/*
* passing different strings for 'ending' and heredoc string as 'str' to chunk_split()
* 'chunklen' is set to 6E0 for this testcase
*/

echo "*** Testing chunk_split() : different values for 'ending' with heredoc 'str'***\n";

// Initializing required variables
// heredoc string for 'str' argument
$heredoc_str = <<<EOT
This is heredoc string with \t and \n.It also contains
sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char.
EOT;

$chunklen = 6E+0;

//different values for 'ending'
$values = array (
  "",  //empty
  " ",  //space
  "a",  //single char
  "ENDING",  //regular string
  "\r\n",  //White space char
  "123",  //Numeric
  ")speci@! ch@r$(",  //String with special chars
);

//loop through each values for 'ending'
for($count = 0; $count < count($values); $count++) {
  echo "-- Iteration ".($count+1). " --\n";
  var_dump( chunk_split($heredoc_str, $chunklen, $values[$count]) );
}

echo "Done"
?>
--EXPECTF--
*** Testing chunk_split() : different values for 'ending' with heredoc 'str'***
-- Iteration 1 --
string(113) "This is heredoc string with 	 and 
.It also contains
sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char."
-- Iteration 2 --
string(132) "This i s here doc st ring w ith 	  and 
. It als o cont ains
s Peci@!  ch@r$  :) &  number s 222. This i s \k w rong e scape  char. "
-- Iteration 3 --
string(132) "This ias hereadoc staring waith 	 aand 
.aIt alsao contaains
saPeci@!a ch@r$a :) & anumberas 222.aThis ias \k warong eascape achar.a"
-- Iteration 4 --
string(227) "This iENDINGs hereENDINGdoc stENDINGring wENDINGith 	 ENDINGand 
.ENDINGIt alsENDINGo contENDINGains
sENDINGPeci@!ENDING ch@r$ENDING :) & ENDINGnumberENDINGs 222.ENDINGThis iENDINGs \k wENDINGrong eENDINGscape ENDINGchar.ENDING"
-- Iteration 5 --
string(151) "This i
s here
doc st
ring w
ith 	 
and 
.
It als
o cont
ains
s
Peci@!
 ch@r$
 :) & 
number
s 222.
This i
s \k w
rong e
scape 
char.
"
-- Iteration 6 --
string(170) "This i123s here123doc st123ring w123ith 	 123and 
.123It als123o cont123ains
s123Peci@!123 ch@r$123 :) & 123number123s 222.123This i123s \k w123rong e123scape 123char.123"
-- Iteration 7 --
string(398) "This i)speci@! ch@r$(s here)speci@! ch@r$(doc st)speci@! ch@r$(ring w)speci@! ch@r$(ith 	 )speci@! ch@r$(and 
.)speci@! ch@r$(It als)speci@! ch@r$(o cont)speci@! ch@r$(ains
s)speci@! ch@r$(Peci@!)speci@! ch@r$( ch@r$)speci@! ch@r$( :) & )speci@! ch@r$(number)speci@! ch@r$(s 222.)speci@! ch@r$(This i)speci@! ch@r$(s \k w)speci@! ch@r$(rong e)speci@! ch@r$(scape )speci@! ch@r$(char.)speci@! ch@r$("
Done