I have a strange problem with PHP. Basically I was trying to do this:
$string = '¤cy_code';
when I try to echo $string the output is:
¤cy_code
Has anyone encountered this? How can we get around this?
¤
is an HTML entity; browsers will render it as the ¤ symbol.
Always run htmlspecialchars
on any non-HTML text you want to output to avoid unexpected behavior like this.
$string = "¤cy_code";
$escaped_string = htmlspecialchars($string);
echo $escaped_string; // outputs the HTML "&currency_code", which
// appears to the user as "¤cy_code".