请问如何解决php显示中文的问题
我的mysql数据库是中文数据,在php中联接获取后在mozilla中显示为乱码,查看了/etc/php.ini文件,果然语言定义部分没有中文:
# Danish (da) - Dutch (nl) - English (en) - Estonian (et)
# French (fr) - German (de) - Greek-Modern (el)
# Italian (it) - Norwegian (no) - Norwegian Nynorsk (nn) - Korean (kr)
# Portugese (pt) - Luxembourgeois* (ltz)
# Spanish (es) - Swedish (sv) - Catalan (ca) - Czech(cz)
# Polish (pl) - Brazilian Portuguese (pt-br) - Japanese (ja)
# Russian (ru) - Croatian (hr)
#
AddLanguage da .dk
AddLanguage nl .nl
AddLanguage en .en
AddLanguage et .et
AddLanguage fr .fr
AddLanguage de .de
AddLanguage he .he
AddLanguage el .el
AddLanguage it .it
AddLanguage ja .ja
AddLanguage pl .po
AddLanguage kr .kr
AddLanguage pt .pt
AddLanguage nn .nn
AddLanguage no .no
AddLanguage pt-br .pt-br
AddLanguage ltz .ltz
AddLanguage ca .ca
AddLanguage es .es
AddLanguage sv .se
AddLanguage cz .cz
AddLanguage ru .ru
AddLanguage tw .tw
AddLanguage zh-tw .tw
AddLanguage hr .hr
#
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority en da nl et fr de el it ja kr no pl pt pt-br ltz ca es sv tw
请问如果想要正常在mozilla显示中文该怎么做呢. PHP代码开头增加:
header("content-Type: text/html; charset=gb2312"); //让不支持中文的空间支持中文
或者:
设置APACHE web服务器。使APACHE的默认语言为GB18030或者GB2312。 还是不行啊,出现下面的警告
Warning: Cannot add header information - headers already sent by (output started at /var/www/html/index.php3:4) in /var/www/html/index.php3 on line 5
改变apache的配置也不行,apache里的语言类型与php.ini里是一样的. 这句话要放在任何输出之前
PHP代码开头增加:
修改 APACHE 的 httpd.conf 中
AddDefaultCharset GB2312
(有可能需要清空浏览器的缓存) 我在httpd.conf中加了
AddDefaultCharset UTF-8
在php.ini中加了
default_chareset GB2312
后成功了
谢谢各位
页:
[1]