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