It is because the browser, for some reason, is using the wrong character encoding. To make sure this does not happen you should explicitly set the character encoding, like this:
header('Content-Type: text/html; charset=utf-8');
When setting HTTP headers (which is what the above does) it is important to do so before any content is echoed. It is therefore best to set the header as the first thing in your scripts.
It is usually also a good idea to set it in the HTML. Put this in your <head>
(or if you do not have a <head>
then put it before the <title>
and any other content).
<meta charset="utf-8">
So, for example:
<?php
header('Content-Type: text/html; charset=utf-8');
?>
<meta charset="utf-8">
<title>This is my website</title>
<p>Bla bla bla...</p>
If you are using Apache then you can just let it handle the headers for you. This can be done by adding the following to an .htaccess
file. Put it in the root of your website's folder structure.
AddDefaultCharset utf-8
I am not familiar with other servers, but you can also let them do it for you. Search StackOverflow to find out how, or read the server's documentation.