1--TEST-- 2Test chunk_split() function : usage variations - different heredoc strings for 'ending' argument 3--FILE-- 4<?php 5/* 6* passing different heredoc strings as 'ending' argument to chunk_split() 7* 'chunklen' argument is set to 10 8*/ 9 10echo "*** Testing chunk_split() : different heredoc strings for 'ending' argument ***\n"; 11 12// Initializing required variables 13$chunklen = 10; 14$str = "This is str to check with heredoc ending.This\tcontains,\nspeci@! ch@r$ __with wrong \k escape char 222."; 15 16// Null heredoc string 17$heredoc_null = <<<EOT1 18EOT1; 19 20// heredoc string with single character 21$heredoc_char = <<<EOT2 22a 23EOT2; 24 25// simple heredoc string 26$heredoc_str = <<<EOT3 27This is simple heredoc string 28EOT3; 29 30// heredoc with special characters 31$heredoc_spchar = <<<EOT4 32This checks with $, %, &, chars 33EOT4; 34 35// blank heredoc string 36$heredoc_blank = <<<EOT5 37 38EOT5; 39 40// heredoc with different white space characters 41$heredoc_escchar = <<<EOT6 42This checks\t and \nwhite space chars 43EOT6; 44 45// heredoc with multiline 46$heredoc_multiline= <<<EOT7 47This is to check chunk_split 48function with multiline 49heredoc 50EOT7; 51 52// heredoc with quotes and slashes 53$heredoc_quote_slash = <<<EOT8 54"To check " in heredoc".I'm sure it'll \work! 55EOT8; 56 57// different heredoc strings for 'ending' 58$heredoc_arr = array( 59 $heredoc_null, 60 $heredoc_blank, 61 $heredoc_char, 62 $heredoc_str, 63 $heredoc_multiline, 64 $heredoc_spchar, 65 $heredoc_escchar, 66 $heredoc_quote_slash 67); 68 69 70// loop through each element of the heredoc_arr for str 71$count = 0; 72foreach($heredoc_arr as $value) { 73 echo "-- Iteration ".($count+1). " --\n"; 74 var_dump( chunk_split( $str, $chunklen, $value) ); 75 $count++; 76}; 77 78echo "Done" 79?> 80--EXPECT-- 81*** Testing chunk_split() : different heredoc strings for 'ending' argument *** 82-- Iteration 1 -- 83string(102) "This is str to check with heredoc ending.This contains, 84speci@! ch@r$ __with wrong \k escape char 222." 85-- Iteration 2 -- 86string(102) "This is str to check with heredoc ending.This contains, 87speci@! ch@r$ __with wrong \k escape char 222." 88-- Iteration 3 -- 89string(113) "This is star to checka with hereadoc endinga.This contaains, 90specai@! ch@r$ a__with wroang \k escaape char 22a2.a" 91-- Iteration 4 -- 92string(421) "This is stThis is simple heredoc stringr to checkThis is simple heredoc string with hereThis is simple heredoc stringdoc endingThis is simple heredoc string.This contThis is simple heredoc stringains, 93specThis is simple heredoc stringi@! ch@r$ This is simple heredoc string__with wroThis is simple heredoc stringng \k escaThis is simple heredoc stringpe char 22This is simple heredoc string2.This is simple heredoc string" 94-- Iteration 5 -- 95string(762) "This is stThis is to check chunk_split 96function with multiline 97heredocr to checkThis is to check chunk_split 98function with multiline 99heredoc with hereThis is to check chunk_split 100function with multiline 101heredocdoc endingThis is to check chunk_split 102function with multiline 103heredoc.This contThis is to check chunk_split 104function with multiline 105heredocains, 106specThis is to check chunk_split 107function with multiline 108heredoci@! ch@r$ This is to check chunk_split 109function with multiline 110heredoc__with wroThis is to check chunk_split 111function with multiline 112heredocng \k escaThis is to check chunk_split 113function with multiline 114heredocpe char 22This is to check chunk_split 115function with multiline 116heredoc2.This is to check chunk_split 117function with multiline 118heredoc" 119-- Iteration 6 -- 120string(443) "This is stThis checks with $, %, &, charsr to checkThis checks with $, %, &, chars with hereThis checks with $, %, &, charsdoc endingThis checks with $, %, &, chars.This contThis checks with $, %, &, charsains, 121specThis checks with $, %, &, charsi@! ch@r$ This checks with $, %, &, chars__with wroThis checks with $, %, &, charsng \k escaThis checks with $, %, &, charspe char 22This checks with $, %, &, chars2.This checks with $, %, &, chars" 122-- Iteration 7 -- 123string(487) "This is stThis checks and 124white space charsr to checkThis checks and 125white space chars with hereThis checks and 126white space charsdoc endingThis checks and 127white space chars.This contThis checks and 128white space charsains, 129specThis checks and 130white space charsi@! ch@r$ This checks and 131white space chars__with wroThis checks and 132white space charsng \k escaThis checks and 133white space charspe char 22This checks and 134white space chars2.This checks and 135white space chars" 136-- Iteration 8 -- 137string(597) "This is st"To check " in heredoc".I'm sure it'll \work!r to check"To check " in heredoc".I'm sure it'll \work! with here"To check " in heredoc".I'm sure it'll \work!doc ending"To check " in heredoc".I'm sure it'll \work!.This cont"To check " in heredoc".I'm sure it'll \work!ains, 138spec"To check " in heredoc".I'm sure it'll \work!i@! ch@r$ "To check " in heredoc".I'm sure it'll \work!__with wro"To check " in heredoc".I'm sure it'll \work!ng \k esca"To check " in heredoc".I'm sure it'll \work!pe char 22"To check " in heredoc".I'm sure it'll \work!2."To check " in heredoc".I'm sure it'll \work!" 139Done 140