note 93146 added to function.mysql-set-charset
| From: | DanielSchlichtholz at osu1 dot php dot net | Date: | Tue, 25 Aug 2009 16:44:40 +0000 |
| Subject: | note 93146 added to function.mysql-set-charset | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-159881@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 209.41.74.194
Probable Submitter: 77.183.94.128
----
Manual Page -- http://www.php.net/manual/en/function.mysql-set-charset.php
Edit -- https://master.php.net/note/edit/93146
Del: integrated -- https://master.php.net/note/delete/93146/integrated
Del: useless -- https://master.php.net/note/delete/93146/useless
Del: bad code -- https://master.php.net/note/delete/93146/bad+code
Del: spam -- https://master.php.net/note/delete/93146/spam
Del: non-english -- https://master.php.net/note/delete/93146/non-english
Del: in docs -- https://master.php.net/note/delete/93146/in+docs
Del: other reasons-- https://master.php.net/note/delete/93146
Reject -- https://master.php.net/note/reject/93146
Search -- https://master.php.net/manage/user-notes.php