1--TEST-- 2Test chunk_split() function : usage variations - different heredoc strings as 'str' argument 3--FILE-- 4<?php 5/* 6* Passing different heredoc strings as 'str' argument to the chunk_split() 7* with 'chunklen' 4 and default value of 'ending' that is "\r\n" 8*/ 9 10echo "*** Testing chunk_split() : heredoc strings as 'str' argument ***\n"; 11 12// Initializing required variables 13$chunklen = 4; 14 15// Null heredoc string 16$heredoc_null = <<<EOT1 17EOT1; 18 19// heredoc string with single character 20$heredoc_char = <<<EOT2 21a 22EOT2; 23 24// simple heredoc string 25$heredoc_str = <<<EOT3 26This is simple heredoc string 27EOT3; 28 29// heredoc with special characters 30$heredoc_spchar = <<<EOT4 31This checks heredoc with $, %, &, chars 32EOT4; 33 34// blank heredoc string 35$heredoc_blank = <<<EOT5 36 37EOT5; 38 39// heredoc with different white space characters 40$heredoc_escchar = <<<EOT6 41This checks\t chunk_split()\nEscape\rchars 42EOT6; 43 44// heredoc with multiline 45$heredoc_multiline= <<<EOT7 46This is to check chunk_split 47function with multiline 48heredoc 49EOT7; 50 51// heredoc with quotes and slashes 52$heredoc_quote_slash = <<<EOT8 53"To check " in heredoc" 54I'm sure it'll work also with \ 55which is single slash 56EOT8; 57 58//different heredoc strings for 'str' 59$heredoc_arr = array( 60 $heredoc_null, 61 $heredoc_blank, 62 $heredoc_char, 63 $heredoc_str, 64 $heredoc_multiline, 65 $heredoc_spchar, 66 $heredoc_escchar, 67 $heredoc_quote_slash 68); 69 70 71// loop through each element of the heredoc_arr for 'str' 72$count = 0; 73foreach($heredoc_arr as $str) { 74 echo "-- Iteration ".($count+1). " --\n"; 75 var_dump( chunk_split( $str, $chunklen) ); 76 $count++; 77}; 78 79echo "Done" 80?> 81--EXPECT-- 82*** Testing chunk_split() : heredoc strings as 'str' argument *** 83-- Iteration 1 -- 84string(2) " 85" 86-- Iteration 2 -- 87string(2) " 88" 89-- Iteration 3 -- 90string(3) "a 91" 92-- Iteration 4 -- 93string(45) "This 94 is 95simp 96le h 97ered 98oc s 99trin 100g 101" 102-- Iteration 5 -- 103string(90) "This 104 is 105to c 106heck 107 chu 108nk_s 109plit 110 111fun 112ctio 113n wi 114th m 115ulti 116line 117 118her 119edoc 120" 121-- Iteration 6 -- 122string(59) "This 123 che 124cks 125here 126doc 127with 128 $, 129%, & 130, ch 131ars 132" 133-- Iteration 7 -- 134string(59) "This 135 che 136cks 137 chu 138nk_s 139plit 140() 141E 142scap 143e 143ch 144ars 145" 146-- Iteration 8 -- 147string(117) ""To 148chec 149k " 150in h 151ered 152oc" 153 154I'm 155sure 156 it' 157ll w 158ork 159also 160 wit 161h \ 162 163whic 164h is 165 sin 166gle 167slas 168h 169" 170Done 171