Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

html_entity_decode not decoding ASCII

Tags:

php

Heres my code:

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

It should be echoing "It", but its just echoing the ASCII codes. Am I using the wrong function? I also tried htmlspecialchars_decode and it changes nothing.

like image 264
scarhand Avatar asked Jan 21 '23 13:01

scarhand


1 Answers

Those are not valid entities Actually, they are valid in HTML 4 (and I suppose HTML5 too), but in this case the entities need to be semicolon-terminated for PHP to recognize them:

$string = 'It';

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

like image 107
BoltClock Avatar answered Jan 29 '23 14:01

BoltClock