1--TEST-- 2Test strip_tags() function : usage variations - invalid values for 'str' and '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 $allowable_tags argument 14*/ 15 16echo "*** Testing strip_tags() : usage variations ***\n"; 17 18$strings = array ( 19 "<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>", 20 '<abc>hello</abc> \t\tworld... <ppp>strip_tags_test</ppp>', 21 "<%?php hello\t world?%>", 22 '<%?php hello\t world?%>', 23 "<<htmL>>hello<</htmL>>", 24 '<<htmL>>hello<</htmL>>', 25 "<a.>HtMl text</.a>", 26 '<a.>HtMl text</.a>', 27 "<nnn>I am not a valid html text</nnn>", 28 '<nnn>I am not a valid html text</nnn>', 29 "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>", 30 '<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>', 31); 32 33$quotes = "<nnn><abc><%?<<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--EXPECTF-- 47*** Testing strip_tags() : usage variations *** 48-- Iteration 1 -- 49string(43) "<abc>hello</abc> world... strip_tags_test" 50-- Iteration 2 -- 51string(45) "<abc>hello</abc> \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(37) "<nnn>I am not a valid html text</nnn>" 66-- Iteration 10 -- 67string(37) "<nnn>I am not a valid html text</nnn>" 68-- Iteration 11 -- 69string(73) "<nnn>I am a quoted (") string with special chars like $,\!,\@,\%,\&</nnn>" 70-- Iteration 12 -- 71string(75) "<nnn>I am a quoted (\") string with special chars like \$,\!,\@,\%,\&</nnn>" 72Done 73