1--TEST--
2Test chunk_split() function : usage variations - different strings for 'ending' with heredoc 'str'
3--FILE--
4<?php
5/* Prototype  : string chunk_split(string $str [, int $chunklen [, string $ending]])
6 * Description: Returns split line
7 * Source code: ext/standard/string.c
8 * Alias to functions: none
9*/
10
11/*
12* passing different strings for 'ending' and heredoc string as 'str' to chunk_split()
13* 'chunklen' is set to 6E0 for this testcase
14*/
15
16echo "*** Testing chunk_split() : different values for 'ending' with heredoc 'str'***\n";
17
18// Initializing required variables
19// heredoc string for 'str' argument
20$heredoc_str = <<<EOT
21This is heredoc string with \t and \n.It also contains
22sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char.
23EOT;
24
25$chunklen = 6E+0;
26
27//different values for 'ending'
28$values = array (
29  "",  //empty
30  " ",  //space
31  "a",  //single char
32  "ENDING",  //regular string
33  "\r\n",  //White space char
34  "123",  //Numeric
35  ")speci@! ch@r$(",  //String with special chars
36);
37
38//loop through each values for 'ending'
39for($count = 0; $count < count($values); $count++) {
40  echo "-- Iteration ".($count+1). " --\n";
41  var_dump( chunk_split($heredoc_str, $chunklen, $values[$count]) );
42}
43
44echo "Done"
45?>
46--EXPECTF--
47*** Testing chunk_split() : different values for 'ending' with heredoc 'str'***
48-- Iteration 1 --
49string(113) "This is heredoc string with 	 and
50.It also contains
51sPeci@! ch@r$ :) & numbers 222.This is \k wrong escape char."
52-- Iteration 2 --
53string(132) "This i s here doc st ring w ith 	  and
54. It als o cont ains
55s Peci@!  ch@r$  :) &  number s 222. This i s \k w rong e scape  char. "
56-- Iteration 3 --
57string(132) "This ias hereadoc staring waith 	 aand
58.aIt alsao contaains
59saPeci@!a ch@r$a :) & anumberas 222.aThis ias \k warong eascape achar.a"
60-- Iteration 4 --
61string(227) "This iENDINGs hereENDINGdoc stENDINGring wENDINGith 	 ENDINGand
62.ENDINGIt alsENDINGo contENDINGains
63sENDINGPeci@!ENDING ch@r$ENDING :) & ENDINGnumberENDINGs 222.ENDINGThis iENDINGs \k wENDINGrong eENDINGscape ENDINGchar.ENDING"
64-- Iteration 5 --
65string(151) "This i
66s here
67doc st
68ring w
69ith
70and
71.
72It als
73o cont
74ains
75s
76Peci@!
77 ch@r$
78 :) &
79number
80s 222.
81This i
82s \k w
83rong e
84scape
85char.
86"
87-- Iteration 6 --
88string(170) "This i123s here123doc st123ring w123ith 	 123and
89.123It als123o cont123ains
90s123Peci@!123 ch@r$123 :) & 123number123s 222.123This i123s \k w123rong e123scape 123char.123"
91-- Iteration 7 --
92string(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
93.)speci@! ch@r$(It als)speci@! ch@r$(o cont)speci@! ch@r$(ains
94s)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$("
95Done
96