Yes, that's all very cool.
Just don't understand, why noy use two str_replace consequently:
$a = str_replace('>', '>', $a);
$a = str_replace('<', '<', $a);
echo $a;
And, BTW, htmlentities() is NOT "aka htmlspecialchars()". They are different a lot.