I have a PHP website in Spanish. Unfortunately some characters like ñ or á are replaced by a �.
I have read lots of papers regarding how to solve it without any success.
Here the code:
<div>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<?php
include ("head_spanish.html");
include ("menu_spanish.html");
include ("/home/libroman/php_library/database.php");
header('Content-Type: text/html; charset=utf-8' );
ini_set('default_charset', 'utf-8');
?>
<div class="bordergrey_bottom text_red">
<h2 class="margin_0 padding_3 text_140">
<p>
Here I enter some Spanish text
</p>
</h2>
</div>
Any help would be really appreciated.
Thanks a lot.
Text editor should be working fine. For instance, I have made other pure HTML pages where all characters are showed well. The issue is only with PHP pages.
If I open the page wuth Mozzila Firefox, press F10 to activate menu and then View->Text encoding-> and select Western, all looks well, so I think the issue is with the character encoding.
Before your header() declaration which means that you will most likely see headers already sent error if you ever turn on your error logs. Error logs are basically the best way to debug your code and figure out why it isn’t doing what you expect it to do. Sometimes, the errors might be obvious and point you in the obvious direction.
Here, I suggest placing the two lines that have to deal with the page configuration first at the top of your page before doing anything else.