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