1--TEST-- 2Test strip_tags() function : usage variations - unexpected values for '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 unexpected values for $allowable_tags argument 12*/ 13 14echo "*** Testing strip_tags() : usage variations ***\n"; 15 16// Initialise function argument 17$string = "<html><a>hello</a></html><p>world</p><!-- COMMENT --><?php echo hello ?>"; 18 19//get an unset variable 20$unset_var = 10; 21unset ($unset_var); 22 23//get a resource variable 24$fp = fopen(__FILE__, "r"); 25 26//get a class 27class classA{ 28 public function __toString(){ 29 return "Class A Object"; 30 } 31} 32 33//array of values to iterate over 34$values = array( 35 36 // int data 37 0, 38 1, 39 12345, 40 -2345, 41 42 // float data 43 10.5, 44 -10.5, 45 10.5e10, 46 10.6E-10, 47 .5, 48 49 // null data 50 NULL, 51 null, 52 53 // boolean data 54 true, 55 false, 56 TRUE, 57 FALSE, 58 59 // empty data 60 "", 61 '', 62 63 // object data 64 new classA(), 65 66 // undefined data 67 @$undefined_var, 68 69 // unset data 70 @$unset_var, 71 72 // resource variable 73 $fp 74); 75 76// loop through each element of the array for allowable_tags 77$iterator = 1; 78foreach($values as $value) { 79 echo "-- Iteration $iterator --\n"; 80 var_dump( strip_tags($string, $value) ); 81 $iterator++; 82}; 83 84echo "Done"; 85?> 86--EXPECT-- 87*** Testing strip_tags() : usage variations *** 88-- Iteration 1 -- 89string(10) "helloworld" 90-- Iteration 2 -- 91string(10) "helloworld" 92-- Iteration 3 -- 93string(10) "helloworld" 94-- Iteration 4 -- 95string(10) "helloworld" 96-- Iteration 5 -- 97string(10) "helloworld" 98-- Iteration 6 -- 99string(10) "helloworld" 100-- Iteration 7 -- 101string(10) "helloworld" 102-- Iteration 8 -- 103string(10) "helloworld" 104-- Iteration 9 -- 105string(10) "helloworld" 106-- Iteration 10 -- 107string(10) "helloworld" 108-- Iteration 11 -- 109string(10) "helloworld" 110-- Iteration 12 -- 111string(10) "helloworld" 112-- Iteration 13 -- 113string(10) "helloworld" 114-- Iteration 14 -- 115string(10) "helloworld" 116-- Iteration 15 -- 117string(10) "helloworld" 118-- Iteration 16 -- 119string(10) "helloworld" 120-- Iteration 17 -- 121string(10) "helloworld" 122-- Iteration 18 -- 123string(10) "helloworld" 124-- Iteration 19 -- 125string(10) "helloworld" 126-- Iteration 20 -- 127string(10) "helloworld" 128-- Iteration 21 -- 129string(10) "helloworld" 130Done 131