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