1--TEST--
2Test strip_tags() function : usage variations - invalid values for 'str' and valid 'allowable_tags'
3--INI--
4short_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
16echo "*** 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;
39foreach($strings as $string_value)
40{
41      echo "-- Iteration $iterator --\n";
42      var_dump( strip_tags($string_value, $quotes) );
43      $iterator++;
44}
45
46echo "Done";
47?>
48--EXPECTF--
49*** Testing strip_tags() : usage variations ***
50-- Iteration 1 --
51string(32) "hello 		world... strip_tags_test"
52-- Iteration 2 --
53string(34) "hello \t\tworld... strip_tags_test"
54-- Iteration 3 --
55string(0) ""
56-- Iteration 4 --
57string(0) ""
58-- Iteration 5 --
59string(18) "<htmL>hello</htmL>"
60-- Iteration 6 --
61string(18) "<htmL>hello</htmL>"
62-- Iteration 7 --
63string(9) "HtMl text"
64-- Iteration 8 --
65string(9) "HtMl text"
66-- Iteration 9 --
67string(26) "I am not a valid html text"
68-- Iteration 10 --
69string(26) "I am not a valid html text"
70-- Iteration 11 --
71string(62) "I am a quoted (") string with special chars like $,\!,\@,\%,\&"
72-- Iteration 12 --
73string(64) "I am a quoted (\") string with special chars like \$,\!,\@,\%,\&"
74Done
75