在utf-8中为php页面强制编码

gee*_*ide 2 php apache debian encoding utf-8

我有一个VPS(Debian,Apache,MySQL,PHP)

我想强制UTF-8编码.我把这一行:

header('Content-type: application/json; charset: UTF-8');
Run Code Online (Sandbox Code Playgroud)

但是charset仍然是ISO8859

我还编辑了php.ini:/etc/php5/apache2/php.ini

mbstring.language=UTF-8
mbstring.internal_encoding= UTF-8
mbstring.http_input=UTF-8
mbstring.http_output=UTF-8
mbstring.detect_order= auto
Run Code Online (Sandbox Code Playgroud)

和apache conf:

nano /etc/apache2/conf.d/charset
AddDefaultCharset UTF-8
Run Code Online (Sandbox Code Playgroud)

iOS应用程序正在调用我的php页面.我给它一个JSON输出.但它收到了ISO charset ......

mar*_*rio 6

您的回复标头不正确:

header('Content-type: application/json; charset: UTF-8');
Run Code Online (Sandbox Code Playgroud)

它应该是:

header('Content-type: application/json; charset=UTF-8');
Run Code Online (Sandbox Code Playgroud)

请注意=代替: