1--TEST-- 2Test htmlspecialchars_decode() function : usage variations - numerical entities for basic characters 3--FILE-- 4<?php 5$tests = array( 6 """, """, """, 7 "'", "'", "'", 8 "&", "&", "<", 9 ">", "<", "<", 10 "<", ">", ">", 11 "?" 12); 13 14echo "*** HTML 4.01/ENT_QUOTES ***\n"; 15 16foreach ($tests as $t) { 17 $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML401); 18 if ($t == $dec) { 19 echo "$t\tNOT DECODED\n"; 20 } else { 21 echo "$t\tDECODED\n"; 22 } 23} 24 25echo "\n*** XHTML 1.0/ENT_QUOTES ***\n"; 26 27foreach ($tests as $t) { 28 $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XHTML); 29 if ($t == $dec) { 30 echo "$t\tNOT DECODED\n"; 31 } else { 32 echo "$t\tDECODED\n"; 33 } 34} 35 36echo "\n*** HTML5/ENT_QUOTES ***\n"; 37 38foreach ($tests as $t) { 39 $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_HTML5); 40 if ($t == $dec) { 41 echo "$t\tNOT DECODED\n"; 42 } else { 43 echo "$t\tDECODED\n"; 44 } 45} 46 47echo "\n*** XML 1.0/ENT_QUOTES ***\n"; 48 49foreach ($tests as $t) { 50 $dec = htmlspecialchars_decode($t, ENT_QUOTES | ENT_XML1); 51 if ($t == $dec) { 52 echo "$t\tNOT DECODED\n"; 53 } else { 54 echo "$t\tDECODED\n"; 55 } 56} 57 58echo "\n*** HTML5/ENT_NOQUOTES ***\n"; 59 60foreach ($tests as $t) { 61 $dec = htmlspecialchars_decode($t, ENT_NOQUOTES | ENT_HTML5); 62 if ($t == $dec) { 63 echo "$t\tNOT DECODED\n"; 64 } else { 65 echo "$t\tDECODED\n"; 66 } 67} 68 69echo "\n*** HTML5/ENT_COMPAT ***\n"; 70 71foreach ($tests as $t) { 72 $dec = htmlspecialchars_decode($t, ENT_COMPAT | ENT_HTML5); 73 if ($t == $dec) { 74 echo "$t\tNOT DECODED\n"; 75 } else { 76 echo "$t\tDECODED\n"; 77 } 78} 79 80 81echo "\nDone.\n"; 82?> 83--EXPECT-- 84*** HTML 4.01/ENT_QUOTES *** 85" DECODED 86" DECODED 87" DECODED 88' NOT DECODED 89' DECODED 90' DECODED 91& DECODED 92& DECODED 93< DECODED 94> DECODED 95< DECODED 96< DECODED 97< DECODED 98> DECODED 99> DECODED 100? NOT DECODED 101 102*** XHTML 1.0/ENT_QUOTES *** 103" DECODED 104" DECODED 105" DECODED 106' DECODED 107' DECODED 108' DECODED 109& DECODED 110& DECODED 111< DECODED 112> DECODED 113< DECODED 114< DECODED 115< DECODED 116> DECODED 117> DECODED 118? NOT DECODED 119 120*** HTML5/ENT_QUOTES *** 121" DECODED 122" DECODED 123" DECODED 124' DECODED 125' DECODED 126' DECODED 127& DECODED 128& DECODED 129< DECODED 130> DECODED 131< DECODED 132< DECODED 133< DECODED 134> DECODED 135> DECODED 136? NOT DECODED 137 138*** XML 1.0/ENT_QUOTES *** 139" DECODED 140" DECODED 141" DECODED 142' DECODED 143' DECODED 144' DECODED 145& DECODED 146& DECODED 147< DECODED 148> DECODED 149< DECODED 150< DECODED 151< DECODED 152> DECODED 153> DECODED 154? NOT DECODED 155 156*** HTML5/ENT_NOQUOTES *** 157" NOT DECODED 158" NOT DECODED 159" NOT DECODED 160' NOT DECODED 161' NOT DECODED 162' NOT DECODED 163& DECODED 164& DECODED 165< DECODED 166> DECODED 167< DECODED 168< DECODED 169< DECODED 170> DECODED 171> DECODED 172? NOT DECODED 173 174*** HTML5/ENT_COMPAT *** 175" DECODED 176" DECODED 177" DECODED 178' NOT DECODED 179' NOT DECODED 180' NOT DECODED 181& DECODED 182& DECODED 183< DECODED 184> DECODED 185< DECODED 186< DECODED 187< DECODED 188> DECODED 189> DECODED 190? NOT DECODED 191 192Done. 193