marcin_koss
marcin_koss

Reputation: 5882

Charcter encoding and PHP

I'm building a multilingual website that uses PHP to load language files. Paragraphs in the language file are set in define() constants. After opening page in the browser I get a bunch of characters like "?". In the markup I have encoding set to utf-8. What can be done to make it work other than replacing all unknown characters with html character entities?

Upvotes: 0

Views: 158

Answers (2)

Ben
Ben

Reputation: 21249

  1. Make sure you language files are utf8,
  2. make sure your HTML files and template are utf8,
  3. make sure you add the following tag to your page

    < meta http-equiv="Content-Type" content="text/html; charset=UTF-8" / >

as long as your data is utf8, the template and html files are utf8 and you explicitely specify the html page is utf8, it should work.

EDIT: the code embedding thing is a bit broken today... have to insert a space at the tag opening.weird

Upvotes: 1

Jhon Hammer
Jhon Hammer

Reputation: 69

header('Content-Type:text/html; charset=UTF-8');

use this line on the top of your PHP code to send header; also helps with validation of dynamic pages to get rid of utf warning.

Upvotes: 3

Related Questions