Question:
I need to transform a string into UTF-8 encoding. I'm declaring it like this:
$nome = utf8_encode($nome);
And still I can't find the error.
The string appears like this:
Consolação
Answer:
If you're having browser problems, you're probably using the wrong encoding.
Add the <meta charset="utf-8" />
header to the head
section of your page, as follows:
<html lang="pt-br">
<head>
<meta charset="utf-8" />
Preferably put it at the beginning, preferably before the <title>
tag, which can usually be changed by the user, as in a search. Security flaws can occur in older browsers if this is not followed ( source ).