I’m trying to output the unicode for a character as a the return type for my PHP function, but when I call the function in practice it just outputs the code without the “0x” rather than a symbol. However, if I explicitly state the unicode in my HTML, it outputs the symbol fine. Below is a simplified version of my code. Why is this happening?
In a PHP file displaying a table:
<td><?php echo verifyMatch($a,$b) ?></td>
In my function in another file:
function verifyMatch($_a,$_b){
$_output = null;
if (checkCondition()){
$_output = 0x2714;
// unicode for tick
} else {
$_output = 0x2718;
// unicode for cross
}
return $_output;
}
As far as PHP is concerned, your values
0x2714and0x2718are simply hexadecimal numbers and they are stored as just2714and2718, respectively. In actuality, PHP should be converting them to their decimal values instead. When outputted into HTML, they are being outputted as just that – numbers.If you want to output them in HTML and have the actual symbols appear, try pre-pending them with

nd appending them with a;:If they are being converted to their decimal values, you can prepend them with just
&#instead of&#x. The addedxis for the hex-values.