1--TEST-- 2Test chop() function : usage variations - with heredoc string 3--FILE-- 4<?php 5/* Prototype : string chop ( string $str [, string $charlist] ) 6 * Description: Strip whitespace (or other characters) from the end of a string 7 * Source code: ext/standard/string.c 8*/ 9 10/* 11 * Testing chop() : with heredoc strings 12*/ 13 14echo "*** Testing chop() : with heredoc strings ***\n"; 15 16// defining different heredoc strings 17$empty_heredoc = <<<EOT 18EOT; 19 20$heredoc_with_newline = <<<EOT 21\n 22 23EOT; 24 25$heredoc_with_characters = <<<EOT 26first line of heredoc string 27second line of heredoc string 28third line of heredocstring 29EOT; 30 31$heredoc_with_newline_and_tabs = <<<EOT 32hello\tworld\nhello\nworld\n 33EOT; 34 35$heredoc_with_alphanumerics = <<<EOT 36hello123world456 371234hello\t1234 38EOT; 39 40$heredoc_with_embedded_nulls = <<<EOT 41hello\0world\0hello 42\0hello\0 43EOT; 44 45$heredoc_strings = array( 46 $empty_heredoc, 47 $heredoc_with_newline, 48 $heredoc_with_characters, 49 $heredoc_with_newline_and_tabs, 50 $heredoc_with_alphanumerics, 51 $heredoc_with_embedded_nulls 52 ); 53$count = 1; 54foreach($heredoc_strings as $string) { 55 echo "\n--- Iteration $count ---\n"; 56 var_dump( chop($string) ); 57 var_dump( chop($string, "12345o\0\n\t") ); 58 $count++; 59} 60 61echo "Done\n"; 62?> 63--EXPECT-- 64*** Testing chop() : with heredoc strings *** 65 66--- Iteration 1 --- 67string(0) "" 68string(0) "" 69 70--- Iteration 2 --- 71string(0) "" 72string(0) "" 73 74--- Iteration 3 --- 75string(86) "first line of heredoc string 76second line of heredoc string 77third line of heredocstring" 78string(86) "first line of heredoc string 79second line of heredoc string 80third line of heredocstring" 81 82--- Iteration 4 --- 83string(23) "hello world 84hello 85world" 86string(23) "hello world 87hello 88world" 89 90--- Iteration 5 --- 91string(31) "hello123world456 921234hello 1234" 93string(25) "hello123world456 941234hell" 95 96--- Iteration 6 --- 97string(24) "helloworldhello 98hello" 99string(23) "helloworldhello 100hell" 101Done 102