Annotation of embedaddon/php/ext/standard/tests/strings/strip_tags_variation4.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
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: * testing functionality of strip_tags() by giving invalid values for $str and valid values for $allowable_tags argument
14: */
15:
16: echo "*** Testing strip_tags() : usage variations ***\n";
17:
18: // unexpected values for $string
19: $strings = array (
20: "<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>",
21: '<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>',
22: "<%?php hello\t world?%>",
23: '<%?php hello\t world?%>',
24: "<<htmL>>hello<</htmL>>",
25: '<<htmL>>hello<</htmL>>',
26: "<a.>HtMl text</.a>",
27: '<a.>HtMl text</.a>',
28: "<nnn>I am not a valid html text</nnn>",
29: '<nnn>I am not a valid html text</nnn>',
30: "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>",
31: '<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>',
32: );
33:
34: //valid html and php tags
35: $quotes = "<p><a><?php<html>";
36:
37: //loop through the various elements of strings array to test strip_tags() functionality
38: $iterator = 1;
39: foreach($strings as $string_value)
40: {
41: echo "-- Iteration $iterator --\n";
42: var_dump( strip_tags($string_value, $quotes) );
43: $iterator++;
44: }
45:
46: echo "Done";
47: ?>
48: --EXPECTF--
49: *** Testing strip_tags() : usage variations ***
50: -- Iteration 1 --
51: string(32) "hello world... strip_tags_test"
52: -- Iteration 2 --
53: string(34) "hello \t\tworld... strip_tags_test"
54: -- Iteration 3 --
55: string(0) ""
56: -- Iteration 4 --
57: string(0) ""
58: -- Iteration 5 --
59: string(18) "<htmL>hello</htmL>"
60: -- Iteration 6 --
61: string(18) "<htmL>hello</htmL>"
62: -- Iteration 7 --
63: string(9) "HtMl text"
64: -- Iteration 8 --
65: string(9) "HtMl text"
66: -- Iteration 9 --
67: string(26) "I am not a valid html text"
68: -- Iteration 10 --
69: string(26) "I am not a valid html text"
70: -- Iteration 11 --
71: string(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&"
72: -- Iteration 12 --
73: string(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&"
74: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>