Annotation of embedaddon/php/ext/standard/tests/strings/chop_variation3.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test 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:
14: echo "*** Testing chop() : with heredoc strings ***\n";
15:
16: // defining different heredoc strings
17: $empty_heredoc = <<<EOT
18: EOT;
19:
20: $heredoc_with_newline = <<<EOT
21: \n
22:
23: EOT;
24:
25: $heredoc_with_characters = <<<EOT
26: first line of heredoc string
27: second line of heredoc string
28: third line of heredocstring
29: EOT;
30:
31: $heredoc_with_newline_and_tabs = <<<EOT
32: hello\tworld\nhello\nworld\n
33: EOT;
34:
35: $heredoc_with_alphanumerics = <<<EOT
36: hello123world456
37: 1234hello\t1234
38: EOT;
39:
40: $heredoc_with_embedded_nulls = <<<EOT
41: hello\0world\0hello
42: \0hello\0
43: EOT;
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;
54: foreach($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:
61: echo "Done\n";
62: ?>
63: --EXPECTF--
64: *** Testing chop() : with heredoc strings ***
65:
66: --- Iteration 1 ---
67: string(0) ""
68: string(0) ""
69:
70: --- Iteration 2 ---
71: string(0) ""
72: string(0) ""
73:
74: --- Iteration 3 ---
75: string(86) "first line of heredoc string
76: second line of heredoc string
77: third line of heredocstring"
78: string(86) "first line of heredoc string
79: second line of heredoc string
80: third line of heredocstring"
81:
82: --- Iteration 4 ---
83: string(23) "hello world
84: hello
85: world"
86: string(23) "hello world
87: hello
88: world"
89:
90: --- Iteration 5 ---
91: string(31) "hello123world456
92: 1234hello 1234"
93: string(25) "hello123world456
94: 1234hell"
95:
96: --- Iteration 6 ---
97: string(24) "hello world hello
98: