1--TEST-- 2Test htmlspecialchars_decode() function : usage variations - unexpected values for 'quote_style' argument 3--FILE-- 4<?php 5/* Prototype : string htmlspecialchars_decode(string $string [, int $quote_style]) 6 * Description: Convert special HTML entities back to characters 7 * Source code: ext/standard/html.c 8*/ 9 10/* 11 * testing htmlspecialchars_decode() by giving unexpected input values for $quote_style argument 12*/ 13 14echo "*** Testing htmlspecialchars_decode() : usage variations ***\n"; 15 16// Initialise function arguments 17// value initialized = Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string " 18$string = "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>"; 19 20//get a class 21class classA { 22 function __toString() { 23 return "Class A Object"; 24 } 25} 26 27//get a resource variable 28$file_handle = fopen(__FILE__, "r"); 29 30//get an unset variable 31$unset_var = 10; 32unset($unset_var); 33 34//array of values to iterate over 35$values = array( 36 37 // float data 38 10.5, 39 -10.5, 40 10.5e20, 41 10.6E-10, 42 .5, 43 44 // array data 45 array(), 46 array(0), 47 array(1), 48 array(1, 2), 49 array('color' => 'red', 'item' => 'pen'), 50 51 // null data 52 NULL, 53 null, 54 55 // boolean data 56 true, 57 false, 58 TRUE, 59 FALSE, 60 61 // empty data 62 "", 63 '', 64 65 // string data 66 "string", 67 'string', 68 69 // object data 70 new classA(), 71 72 // undefined data 73 @$undefined_var, 74 75 // unset data 76 @$unset_var, 77 78 //resource 79 $file_handle 80); 81 82// loop through each element of the array for quote_style 83$iterator = 1; 84foreach($values as $value) { 85 echo "\n-- Iteration $iterator --\n"; 86 var_dump( htmlspecialchars_decode($string, $value) ); 87 $iterator++; 88} 89 90// close the file resource used 91fclose($file_handle); 92 93echo "Done"; 94?> 95--EXPECTF-- 96*** Testing htmlspecialchars_decode() : usage variations *** 97 98-- Iteration 1 -- 99string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 100 101-- Iteration 2 -- 102string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 103 104-- Iteration 3 -- 105string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 106 107-- Iteration 4 -- 108string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 109 110-- Iteration 5 -- 111string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 112 113-- Iteration 6 -- 114 115Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d 116NULL 117 118-- Iteration 7 -- 119 120Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d 121NULL 122 123-- Iteration 8 -- 124 125Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d 126NULL 127 128-- Iteration 9 -- 129 130Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d 131NULL 132 133-- Iteration 10 -- 134 135Warning: htmlspecialchars_decode() expects parameter 2 to be long, array given in %shtmlspecialchars_decode_variation2.php on line %d 136NULL 137 138-- Iteration 11 -- 139string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 140 141-- Iteration 12 -- 142string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 143 144-- Iteration 13 -- 145string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 146 147-- Iteration 14 -- 148string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 149 150-- Iteration 15 -- 151string(104) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 152 153-- Iteration 16 -- 154string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 155 156-- Iteration 17 -- 157 158Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d 159NULL 160 161-- Iteration 18 -- 162 163Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d 164NULL 165 166-- Iteration 19 -- 167 168Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d 169NULL 170 171-- Iteration 20 -- 172 173Warning: htmlspecialchars_decode() expects parameter 2 to be long, string given in %shtmlspecialchars_decode_variation2.php on line %d 174NULL 175 176-- Iteration 21 -- 177 178Warning: htmlspecialchars_decode() expects parameter 2 to be long, object given in %shtmlspecialchars_decode_variation2.php on line %d 179NULL 180 181-- Iteration 22 -- 182string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 183 184-- Iteration 23 -- 185string(114) "<html>Roy's height > Sam's height. 13 < 15. 1111 & 0000 = 0000. " double quote string "</html>" 186 187-- Iteration 24 -- 188 189Warning: htmlspecialchars_decode() expects parameter 2 to be long, resource given in %shtmlspecialchars_decode_variation2.php on line %d 190NULL 191Done 192