Annotation of embedaddon/php/ext/standard/tests/strings/strip_tags_basic2.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test strip_tags() function : basic functionality - with all arguments
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: echo "*** Testing strip_tags() : basic functionality ***\n";
13:
14: // Calling strip_tags() with all possible arguments
15: $string = "<html><p>hello</p><b>world</b><a href=\"#fragment\">Other text</a></html><?php echo hello ?>";
16:
17: $allowed_tags_array=array(
18: "<html>",
19: '<html>',
20: "<p>",
21: '<p>',
22: "<a>",
23: '<a>',
24: "<?php",
25: '<?php',
26: "<html><p><a><?php"
27: );
28:
29: // loop through the $string with various $allowed_tags_array to test strip_tags
30: // on various allowed tags
31: $iteration = 1;
32: foreach($allowed_tags_array as $tags)
33: {
34: echo "-- Iteration $iteration --\n";
35: var_dump( strip_tags($string, $tags) );
36: $iteration++;
37: }
38:
39: echo "Done";
40: ?>
41: --EXPECTF--
42: *** Testing strip_tags() : basic functionality ***
43: -- Iteration 1 --
44: string(33) "<html>helloworldOther text</html>"
45: -- Iteration 2 --
46: string(33) "<html>helloworldOther text</html>"
47: -- Iteration 3 --
48: string(27) "<p>hello</p>worldOther text"
49: -- Iteration 4 --
50: string(27) "<p>hello</p>worldOther text"
51: -- Iteration 5 --
52: string(44) "helloworld<a href="#fragment">Other text</a>"
53: -- Iteration 6 --
54: string(44) "helloworld<a href="#fragment">Other text</a>"
55: -- Iteration 7 --
56: string(20) "helloworldOther text"
57: -- Iteration 8 --
58: string(20) "helloworldOther text"
59: -- Iteration 9 --
60: string(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>"
61: Done
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>