Html_entity_decode does not decode ASCII

Here is my code:

$string = '&#73&#116'; $string = html_entity_decode($string); echo $string; 

This should be an echo of β€œThis,” but it just repeats the ASCII codes. Am I using the wrong function? I also tried htmlspecialchars_decode and does not change anything.

+4
source share
1 answer

These invalid entities They are actually valid in HTML 4 (and I suppose HTML5 too), but in this case the entities must be with a semicolon so that PHP recognizes them:

 $string = 'It'; 

htmlspecialchars_decode() only decodes < , > , & , ' and " (and the last two depend on the quotes flag).

+9
source

Source: https://habr.com/ru/post/1338580/


All Articles