<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
http-equiv
attribute provides an HTTP header for the information/value of the content attribute.- The
content
attribute gives the value associated with the http-equiv or name attribute. - The
charset
attribute specifies the character encoding for the HTML document.
Effectively, the above <meta>
declaration will instruct the browser to have text/html
type of document with the character set set to UTF-8.
Including the meta declaration won't make much of a difference if the Content-Type
header is already served over HTTP. That is, the real HTTP header takes precedence over everything (UTF BOM is an exception) except user override. The charset
attribute is just meant as a fallback and will only be used if the document decoding using the charset specified in the HTTP header fails.
Note that this is pointless if the file is not saved as UTF-8. The charset
will be effective only if the file is saved as UTF-8. To save it as UTF-8, you can simply add a Byte Order Mark (BOM), at the very beginning of the file:
$contents = file_get_contents('yourFile.ext');
file_put_contents($your_file, "\xEF\xBB\xBF".$content);
See also: