Return to strip_tags_variation2.phpt CVS log | Up to [ELWIX - Embedded LightWeight unIX -] / embedaddon / php / ext / standard / tests / strings |
1.1 misho 1: --TEST-- 2: Test strip_tags() function : usage variations - unexpected values for 'allowable_tags' 3: --INI-- 4: short_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 unexpected values for $allowable_tags argument 14: */ 15: 16: echo "*** Testing strip_tags() : usage variations ***\n"; 17: 18: // Initialise function argument 19: $string = "<html><a>hello</a></html><p>world</p><!-- COMMENT --><?php echo hello ?>"; 20: 21: //get an unset variable 22: $unset_var = 10; 23: unset ($unset_var); 24: 25: //get a resource variable 26: $fp = fopen(__FILE__, "r"); 27: 28: //get a class 29: class classA{ 30: public function __toString(){ 31: return "Class A Object"; 32: } 33: } 34: 35: //array of values to iterate over 36: $values = array( 37: 38: // int data 39: 0, 40: 1, 41: 12345, 42: -2345, 43: 44: // float data 45: 10.5, 46: -10.5, 47: 10.5e10, 48: 10.6E-10, 49: .5, 50: 51: // array data 52: array(), 53: array(0), 54: array(1), 55: array(1, 2), 56: array('color' => 'red', 'item' => 'pen'), 57: 58: // null data 59: NULL, 60: null, 61: 62: // boolean data 63: true, 64: false, 65: TRUE, 66: FALSE, 67: 68: // empty data 69: "", 70: '', 71: 72: // object data 73: new classA(), 74: 75: // undefined data 76: @$undefined_var, 77: 78: // unset data 79: @$unset_var, 80: 81: // resource variable 82: $fp 83: ); 84: 85: // loop through each element of the array for allowable_tags 86: $iterator = 1; 87: foreach($values as $value) { 88: echo "-- Iteration $iterator --\n"; 89: var_dump( strip_tags($string, $value) ); 90: $iterator++; 91: }; 92: 93: echo "Done"; 94: ?> 95: --EXPECTF-- 96: *** Testing strip_tags() : usage variations *** 97: -- Iteration 1 -- 98: string(10) "helloworld" 99: -- Iteration 2 -- 100: string(10) "helloworld" 101: -- Iteration 3 -- 102: string(10) "helloworld" 103: -- Iteration 4 -- 104: string(10) "helloworld" 105: -- Iteration 5 -- 106: string(10) "helloworld" 107: -- Iteration 6 -- 108: string(10) "helloworld" 109: -- Iteration 7 -- 110: string(10) "helloworld" 111: -- Iteration 8 -- 112: string(10) "helloworld" 113: -- Iteration 9 -- 114: string(10) "helloworld" 115: -- Iteration 10 -- 116: 117: Notice: Array to string conversion in %s on line %d 118: string(10) "helloworld" 119: -- Iteration 11 -- 120: 121: Notice: Array to string conversion in %s on line %d 122: string(10) "helloworld" 123: -- Iteration 12 -- 124: 125: Notice: Array to string conversion in %s on line %d 126: string(10) "helloworld" 127: -- Iteration 13 -- 128: 129: Notice: Array to string conversion in %s on line %d 130: string(10) "helloworld" 131: -- Iteration 14 -- 132: 133: Notice: Array to string conversion in %s on line %d 134: string(10) "helloworld" 135: -- Iteration 15 -- 136: string(10) "helloworld" 137: -- Iteration 16 -- 138: string(10) "helloworld" 139: -- Iteration 17 -- 140: string(10) "helloworld" 141: -- Iteration 18 -- 142: string(10) "helloworld" 143: -- Iteration 19 -- 144: string(10) "helloworld" 145: -- Iteration 20 -- 146: string(10) "helloworld" 147: -- Iteration 21 -- 148: string(10) "helloworld" 149: -- Iteration 22 -- 150: string(10) "helloworld" 151: -- Iteration 23 -- 152: string(10) "helloworld" 153: -- Iteration 24 -- 154: string(10) "helloworld" 155: -- Iteration 25 -- 156: string(10) "helloworld" 157: -- Iteration 26 -- 158: string(10) "helloworld" 159: Done