Reputation: 43788
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)
Upvotes: 1
Views: 994
Reputation: 34437
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
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).
Upvotes: 0
Reputation: 27159
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.
Upvotes: 1
Reputation: 43619
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.
Upvotes: 0