1--TEST-- 2Test strip_tags() function : basic functionality - with all arguments 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 12echo "*** 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; 32foreach($allowed_tags_array as $tags) 33{ 34 echo "-- Iteration $iteration --\n"; 35 var_dump( strip_tags($string, $tags) ); 36 $iteration++; 37} 38 39echo "Done"; 40?> 41--EXPECTF-- 42*** Testing strip_tags() : basic functionality *** 43-- Iteration 1 -- 44string(33) "<html>helloworldOther text</html>" 45-- Iteration 2 -- 46string(33) "<html>helloworldOther text</html>" 47-- Iteration 3 -- 48string(27) "<p>hello</p>worldOther text" 49-- Iteration 4 -- 50string(27) "<p>hello</p>worldOther text" 51-- Iteration 5 -- 52string(44) "helloworld<a href="#fragment">Other text</a>" 53-- Iteration 6 -- 54string(44) "helloworld<a href="#fragment">Other text</a>" 55-- Iteration 7 -- 56string(20) "helloworldOther text" 57-- Iteration 8 -- 58string(20) "helloworldOther text" 59-- Iteration 9 -- 60string(64) "<html><p>hello</p>world<a href="#fragment">Other text</a></html>" 61Done 62