1

Does anyone know how can I default web browser character encoding in php, which I hope all user drop in to the page with using character encoding western (ISO-8859-1)

3 Answers 3

1

Before printing/echoing anything else do this

header('Content-Type: text/html; charset=ISO-8859-1');

This will change HTTP headers and will set the browser's default encoding to ISO-8859-1 for your page, unless the user specifies otherwise via browser's settings.

Sign up to request clarification or add additional context in comments.

Comments

0

You can set the character encoding by outputting the Content-Type header.

header('Content-Type: text/html; charset=ISO-8859-1');

This will tell the browser to use this character set to read your pages.

Comments

0

Instead of writing this header header('Content-Type: text/html; charset=ISO-8859-1'); in each of your web applications you could add this simple line in your .htaccess file

AddDefaultCharset iso-8859-1

It makes Apache to serve out always the charset header.

Otherwise you could set once for all the php.ini directive default_charset to "iso-8859-1". On most web hosters is usually set to empty string. In order to do this once for all you need either to access the server main php.ini file or get an hoster with suPHP that will allow you to use your specific php.ini file in the same way you use .htaccess files. (suPHP is used by almost every webhosters).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.