1--TEST-- 2Test strtok() function : usage variations - with heredoc strings 3--FILE-- 4<?php 5/* 6 * Testing strtok() : with heredoc strings 7*/ 8 9echo "*** Testing strtok() : with heredoc strings ***\n"; 10 11// defining different heredoc strings 12$empty_heredoc = <<<EOT 13EOT; 14 15$heredoc_with_newline = <<<EOT 16\n 17 18EOT; 19 20$heredoc_with_characters = <<<EOT 21first line of heredoc string 22second line of heredoc string 23third line of heredocstring 24EOT; 25 26$heredoc_with_newline_and_tabs = <<<EOT 27hello\tworld\nhello\nworld\n 28EOT; 29 30$heredoc_with_alphanumerics = <<<EOT 31hello123world456 321234hello\t1234 33EOT; 34 35$heredoc_with_embedded_nulls = <<<EOT 36hello\0world\0hello 37\0hello\0 38EOT; 39 40$heredoc_strings = array( 41 $empty_heredoc, 42 $heredoc_with_newline, 43 $heredoc_with_characters, 44 $heredoc_with_newline_and_tabs, 45 $heredoc_with_alphanumerics, 46 $heredoc_with_embedded_nulls 47 ); 48 49// loop through each element of the array and check the working of strtok() 50// when supplied with different string values 51 52$count = 1; 53foreach($heredoc_strings as $string) { 54 echo "\n--- Iteration $count ---\n"; 55 var_dump( strtok($string, "5o\0\n\t") ); 56 for($counter = 1; $counter <= 10; $counter++) { 57 var_dump( strtok("5o\0\n\t") ); 58 } 59 $count++; 60} 61 62 63echo "Done\n"; 64?> 65--EXPECTF-- 66*** Testing strtok() : with heredoc strings *** 67 68--- Iteration 1 --- 69bool(false) 70bool(false) 71bool(false) 72bool(false) 73bool(false) 74bool(false) 75bool(false) 76bool(false) 77bool(false) 78bool(false) 79bool(false) 80 81--- Iteration 2 --- 82bool(false) 83 84Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 85bool(false) 86 87Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 88bool(false) 89 90Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 91bool(false) 92 93Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 94bool(false) 95 96Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 97bool(false) 98 99Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 100bool(false) 101 102Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 103bool(false) 104 105Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 106bool(false) 107 108Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 109bool(false) 110 111Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 112bool(false) 113 114--- Iteration 3 --- 115string(11) "first line " 116string(7) "f hered" 117string(8) "c string" 118string(3) "sec" 119string(8) "nd line " 120string(7) "f hered" 121string(8) "c string" 122string(11) "third line " 123string(7) "f hered" 124string(7) "cstring" 125bool(false) 126 127--- Iteration 4 --- 128string(4) "hell" 129string(1) "w" 130string(3) "rld" 131string(4) "hell" 132string(1) "w" 133string(3) "rld" 134bool(false) 135bool(false) 136bool(false) 137bool(false) 138bool(false) 139 140--- Iteration 5 --- 141string(4) "hell" 142string(4) "123w" 143string(4) "rld4" 144string(1) "6" 145string(8) "1234hell" 146string(4) "1234" 147bool(false) 148bool(false) 149bool(false) 150bool(false) 151bool(false) 152 153--- Iteration 6 --- 154string(4) "hell" 155string(1) "w" 156string(3) "rld" 157string(4) "hell" 158string(4) "hell" 159bool(false) 160 161Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 162bool(false) 163 164Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 165bool(false) 166 167Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 168bool(false) 169 170Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 171bool(false) 172 173Warning: strtok(): Both arguments must be provided when starting tokenization in %s on line %d 174bool(false) 175Done 176