1--TEST--
2Test chop() function : usage variations - with heredoc string
3--FILE--
4<?php
5/*
6 * Testing chop() : with heredoc strings
7*/
8
9echo "*** Testing chop() : 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$count = 1;
49foreach($heredoc_strings as $string)  {
50  echo "\n--- Iteration $count ---\n";
51  var_dump( chop($string) );
52  var_dump( chop($string, "12345o\0\n\t") );
53  $count++;
54}
55
56echo "Done\n";
57?>
58--EXPECTF--
59*** Testing chop() : with heredoc strings ***
60
61--- Iteration 1 ---
62string(0) ""
63string(0) ""
64
65--- Iteration 2 ---
66string(0) ""
67string(0) ""
68
69--- Iteration 3 ---
70string(86) "first line of heredoc string
71second line of heredoc string
72third line of heredocstring"
73string(86) "first line of heredoc string
74second line of heredoc string
75third line of heredocstring"
76
77--- Iteration 4 ---
78string(23) "hello	world
79hello
80world"
81string(23) "hello	world
82hello
83world"
84
85--- Iteration 5 ---
86string(31) "hello123world456
871234hello	1234"
88string(25) "hello123world456
891234hell"
90
91--- Iteration 6 ---
92string(24) "hello%0world%0hello
93%0hello"
94string(23) "hello%0world%0hello
95%0hell"
96Done
97