htmlspecialchars not converting
I have this PHP code:
echo htmlspecialchars("commen<p>commpen", ENT_QUOTES, 'UTF-8');
but it echos out this: commen<p>commpen
Unless I am wrong, that is not what it is meant to output. It should escape the <> to <h; >h;
The only way I have figured out to get around this is by using this header:
header('Content-type: text/plain; charset=utf-8');
Is there a way to do it without the header?
It is outputting <. But your browser is interpreting it as the entity it is and rendering <.
Seriously, try not encoding it, see what happens.