faqts : Computers : Programming : Languages : PHP : Common Problems : HTTP Headers

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

15 of 31 people (48%) answered Yes
Recently 1 of 10 people (10%) answered Yes

Entry

How can I define the character set for a page?

Aug 24th, 2006 15:28
Bazil Hassan, Nathan Wallace, Nick M


Use a PHP command like:

    <?
        // set your charset in $mycharset
        header("Content-type: text/html; charset=$mycharset");
    ?>

and make sure you are using full ISO charsets.

If you want to use UTF-8 encoding make sure to remove BOM from the
begining of the php file saved in UTF-8 encoding. BOM is the first 3
bytes of the file. You need to have a hex editor to perform this
operation because most of the text editors hide it from you.