1--TEST--
2Test strip_tags() function : basic functionality - with all arguments
3--FILE--
4<?php
5/* Prototype  : string strip_tags(string $str [, string $allowable_tags])
6 * Description: Strips HTML and PHP tags from a string
7 * Source code: ext/standard/string.c
8*/
9
10echo "*** Testing strip_tags() : basic functionality ***\n";
11
12// Calling strip_tags() with all possible arguments
13$string = "<html><p>hello</p><b>world</b><a href=\"#fragment\">Other text</a></html><?php echo hello ?>";
14
15$allowed_tags_array=array(
16  "<html>",
17  '<html>',
18  "<p>",
19  '<p>',
20  "<a>",
21  '<a>',
22  "<?php",
23  '<?php',
24  "<html><p><a><?php"
25);
26
27// loop through the $string with various $allowed_tags_array to test strip_tags
28// on various allowed tags
29$iteration = 1;
30foreach($allowed_tags_array as $tags)
31{
32  echo "-- Iteration $iteration --\n";
33  var_dump( strip_tags($string, $tags) );
34  $iteration++;
35}
36
37echo "Done";
38?>
39--EXPECT--
40*** Testing strip_tags() : basic functionality ***
41-- Iteration 1 --
42string(33) "<html>helloworldOther text</html>"
43-- Iteration 2 --
44string(33) "<html>helloworldOther text</html>"
45-- Iteration 3 --
46string(27) "<p>hello</p>worldOther text"
47-- Iteration 4 --
48string(27) "<p>hello</p>worldOther text"
49-- Iteration 5 --
50string(44) "helloworld<a href="#fragment">Other text</a>"
51-- Iteration 6 --
52string(44) "helloworld<a href="#fragment">Other text</a>"
53-- Iteration 7 --
54string(20) "helloworldOther text"
55-- Iteration 8 --
56string(20) "helloworldOther text"
57-- Iteration 9 --
58string(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>"
59Done
60