note 93146 deleted from function.mysql-set-charset by danbrown
| From: | danbrown@php.net | Date: | Tue, 25 Aug 2009 16:46:08 +0000 |
| Subject: | note 93146 deleted from function.mysql-set-charset by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-159882@lists.php.net to get a copy of this message | ||
Note Submitter: Daniel Schlichtholz
----
In reply to Ronald:
<<3. Set your apache environment to utf-8 by adding 'AddDefaultCharset utf-8' to
your .htaccess. If you do not use apache add 'default_charset utf-8' to your php.ini. You
have to do either of them (not both), php will use the apache setting where needed.
As far as I know (correct me if I am wrong):
Apache's AddDefaultCharset directive only applies when your application doesn't send a
header with any charset information (I am not alking about the meta tag inside the HTML-head node.
The "real" header is sent before any HTML is sent. If a header with the charset parameter
is sent, the browser ignores the meta tag and sticks to the charset of the header. Only if the
header doesn't include a charset information at all the browser uses the charset of the meta
tag.)
You can tell the browser the charset of a page by simply sending:
<?php header("Content-Type: text/html; charset=utf-8"); ?>
Just be aware of the fact that you mustn't output any character - not even a single space -
before sending a header. In the browser you can simply check the used charset by opening the menu
"view/encoding".
If you want to do applications that run on any server (regardless of Apache settings) this seems to
be the cleaner approach. Like the name "DefaultCharset" implies, it can be overwritten
with other values. So I don't see any necessity to edit php.ini or httpd.conf.