Annotation of embedaddon/php/ext/standard/tests/strings/strip_tags_variation5.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strip_tags() function : usage variations - heredoc strings
3: --INI--
4: short_open_tag = on
5: --FILE--
6: <?php
7: /* Prototype : string strip_tags(string $str [, string $allowable_tags])
8: * Description: Strips HTML and PHP tags from a string
9: * Source code: ext/standard/string.c
10: */
11:
12:
13: /*
14: * testing functionality of strip_tags() by giving heredoc strings as values for $str argument
15: */
16:
17: echo "*** Testing strip_tags() : usage variations ***\n";
18:
19: // null here doc string
20: $null_string = <<<EOT
21: EOT;
22:
23: // heredoc string with blank line
24: $blank_line = <<<EOT
25:
26: EOT;
27:
28: // here doc with multiline string
29: $multiline_string = <<<EOT
30: <html>hello world</html>
31: <p>13 < 25</p>
32: <?php 1111 & 0000 = 0000 ?>
33: <b>This is a double quoted string</b>
34: EOT;
35:
36: // here doc with diferent whitespaces
37: $diff_whitespaces = <<<EOT
38: <html>hello\r world\t
39: 1111\t\t != 2222\v\v</html>
40: <? heredoc\ndouble quoted string. with\vdifferent\fwhite\vspaces ?>
41: EOT;
42:
43: // here doc with numeric values
44: $numeric_string = <<<EOT
45: <html>11 < 12. 123 >22</html>
46: <p>string</p> 1111\t <b>0000\t = 0000\n</b>
47: EOT;
48:
49: // heredoc with quote chars & slash
50: $quote_char_string = <<<EOT
51: <html>This's a string with quotes:</html>
52: "strings in double quote";
53: 'strings in single quote';
54: <html>this\line is single quoted /with\slashes </html>
55: EOT;
56:
57: $res_heredoc_strings = array(
58: //heredoc strings
59: $null_string,
60: $blank_line,
61: $multiline_string,
62: $diff_whitespaces,
63: $numeric_string,
64: $quote_char_string
65: );
66:
67: // initialize the second argument
68: $quotes = "<html><a><?php";
69:
70: // loop through $res_heredoc_strings element and check the working on strip_tags()
71: $count = 1;
72: for($index =0; $index < count($res_heredoc_strings); $index ++) {
73: echo "-- Iteration $count --\n";
74: var_dump( strip_tags($res_heredoc_strings[$index], $quotes) );
75: $count++;
76: }
77:
78: echo "Done\n";
79: ?>
80: --EXPECTF--
81: *** Testing strip_tags() : usage variations ***
82: -- Iteration 1 --
83: string(0) ""
84: -- Iteration 2 --
85: string(0) ""
86: -- Iteration 3 --
87: string(67) "<html>hello world</html>
88: 13 < 25
89:
90: This is a double quoted string"
91: -- Iteration 4 --
92: string(44) "<html>hello
world
93: 1111 != 2222</html>
94: "
95: -- Iteration 5 --
96: string(56) "<html>11 < 12. 123 >22</html>
97: string 1111 0000 = 0000
98: "
99: -- Iteration 6 --
100: string(150) "<html>This's a string with quotes:</html>
101: "strings in double quote";
102: 'strings in single quote';
103: <html>this\line is single quoted /with\slashes </html>"
104: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>