1--TEST-- 2html_entity_decode: Decoding of entities after invalid entities 3--FILE-- 4<?php 5$arr = array( 6 "&", 7 "&&", 8 "&$", 9 "&#&", 10 "&#$", 11 "&#x&", 12 "&#x$", 13 "&", 14 "$", 15 " &", 16 " $", 17 "&", 18 "$", 19 "&", 20 "$", 21 "&a&", 22 "&a$", 23 "&aa&", 24 "&aa$", 25 "&aa;&", 26 "&aa;$", 27 "&;&", 28 "&;$", 29); 30 31$i = 0; 32foreach ($arr as $ent) { 33 if ($i % 2 == 1) { 34 if (($a = html_entity_decode($ent, ENT_QUOTES, 'UTF-8')) != 35 ($b = htmlspecialchars_decode($ent, ENT_QUOTES))) { 36 echo "htmlspecialchars_decode <-> html_entity_decode inconsistency","\n", 37 "$b <-> $a","\n"; 38 } 39 } 40 echo html_entity_decode($ent, ENT_QUOTES, 'UTF-8'), "\n"; 41} 42echo "Done.\n"; 43--EXPECT-- 44& 45&& 46&$ 47&#& 48&#$ 49&#x& 50&#x$ 51& 52$ 53 & 54 $ 55& 56$ 57& 58$ 59&a& 60&a$ 61&aa& 62&aa$ 63&aa;& 64&aa;$ 65&;& 66&;$ 67Done. 68