Skip to content Skip to sidebar Skip to footer

Html/php Symbol ≈ Outputting As ‰ˆ

I am prefixing some names in a table with '≈' so it would look like ≈Name The output however is ≈Name $name = ''.$name;

Solution 1:

It could be a header problem or a text editor problem.

You may need to send UTF-8 headers. In PHP, before sending anything to the user, try this...

$header_text = 'Content-type: text/html; charset=utf-8';
header($header_text);

This is the preferred solution.

Also, some browsers will also respect an HTML tag in the header of the HTML, like this...

<metahttp-equiv="content-type"content="text/html; charset=UTF-8">

I usually combine these two approaches.

Of course, in certain situations (PDF generators, excel sheet generators, etc.), neither of these solutions may be applicable, and you'll need to make your source code ugly to solve it, with HTML entities...

$name = '<spanstyle="color:white;">&#8776;</span>'.$name;

You will also want to verify that your source code file is actually encoded as UTF-8. Different text editors will have different options in handling charsets. So, the problem could possibly be your text editor not saving correctly.

Post a Comment for "Html/php Symbol ≈ Outputting As ‰ˆ"