1--TEST-- 2Test chunk_split() function : usage variations - different integer values for 'chunklen' with heredoc string as 'str'(Bug#42796) 3--SKIPIF-- 4<?php 5if (PHP_INT_SIZE != 8) die("skip this test is for 64bit platform only"); 6?> 7--FILE-- 8<?php 9/* Prototype : string chunk_split(string $str [, int $chunklen [, string $ending]]) 10 * Description: Returns split line 11 * Source code: ext/standard/string.c 12 * Alias to functions: 13*/ 14 15/* 16* passing different integer values for 'chunklen' and heredoc string for 'str' to chunk_split() 17*/ 18 19echo "*** Testing chunk_split() : different 'chunklen' with heredoc 'str' ***\n"; 20 21 22// Initializing required variables 23//heredoc string as str 24$heredoc_str = <<<EOT 25This's heredoc string with \t and \n white space char. 26It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test 27chunk_split() 28EOT; 29 30$ending = ':::'; 31 32// different values for 'chunklen' 33$values = array ( 34 0, 35 1, 36 -123, //negative integer 37 0234, //octal number 38 0x1A, //hexadecimal number 39 PHP_INT_MAX, // max positive integer number 40 PHP_INT_MAX * 3, // integer overflow 41 -PHP_INT_MAX - 1, // min negative integer 42 43); 44 45 46// loop through each element of values for 'chunklen' 47for($count = 0; $count < count($values); $count++) { 48 echo "-- Iteration ".($count+1). " --\n"; 49 var_dump( chunk_split($heredoc_str, $values[$count], $ending) ); 50} 51 52echo "Done" 53?> 54--EXPECTF-- 55*** Testing chunk_split() : different 'chunklen' with heredoc 'str' *** 56-- Iteration 1 -- 57 58Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d 59bool(false) 60-- Iteration 2 -- 61string(504) "T:::h:::i:::s:::':::s::: :::h:::e:::r:::e:::d:::o:::c::: :::s:::t:::r:::i:::n:::g::: :::w:::i:::t:::h::: ::: ::: :::a:::n:::d::: ::: 62::: :::w:::h:::i:::t:::e::: :::s:::p:::a:::c:::e::: :::c:::h:::a:::r:::.::: 63:::I:::t::: :::h:::a:::s::: :::_:::s:::p:::e:::c:::i:::@:::l::: :::c:::h:::@:::r:::$::: :::2:::2:::2:::2::: :::!:::!:::!:::N:::o:::w::: :::\:::k::: :::a:::s::: :::e:::s:::c:::a:::p:::e::: :::c:::h:::a:::r::: :::t:::o::: :::t:::e:::s:::t::: 64:::c:::h:::u:::n:::k:::_:::s:::p:::l:::i:::t:::(:::):::" 65-- Iteration 3 -- 66 67Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d 68bool(false) 69-- Iteration 4 -- 70string(129) "This's heredoc string with and 71 white space char. 72It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test 73chunk_split():::" 74-- Iteration 5 -- 75string(141) "This's heredoc string with::: and 76 white space char.::: 77It has _speci@l ch@r$ 222:::2 !!!Now \k as escape char::: to test 78chunk_split():::" 79-- Iteration 6 -- 80string(129) "This's heredoc string with and 81 white space char. 82It has _speci@l ch@r$ 2222 !!!Now \k as escape char to test 83chunk_split():::" 84-- Iteration 7 -- 85 86Warning: chunk_split() expects parameter 2 to be int, float given in %s on line %d 87NULL 88-- Iteration 8 -- 89 90Warning: chunk_split(): Chunk length should be greater than zero in %s on line %d 91bool(false) 92Done 93