【问题标题】:Header Type change to application/json not changing标头类型更改为 application/json 未更改
【发布时间】:2014-11-19 05:53:20
【问题描述】:

标题类型 从 "text/html""application/json" 的响应。 除了这个

我使用作为标题类型作为 header("Content-Type", "application/json;charset=UTF-8")

但不会改变。

Status Code: 200 OK
Connection: keep-alive
Content-Type: text/html
Date: Wed, 19 Nov 2014 05:49:55 GMT
Server: Apache mod_fcgid/2.3.10-dev
Vary: User-Agent
Via: 1.1 (external)pdc.amw.lan (squid/3.3.8), 1.1 (frontal)pdc.amw.lan (squid/3.3.8)
X-Cache: MISS from (external)pdc.amw.lan, MISS from (frontal)pdc.amw.lan
X-Cache-Lookup: MISS from (external)pdc.amw.lan:3130, MISS from (frontal)pdc.amw.lan:0
X-Powered-By: PHP/5.4.34

【问题讨论】:

    标签: php api rest mobile


    【解决方案1】:

    如下设置header,不像header("Content-Type", "application/json;charset=UTF-8")

    header("Content-Type: application/json");
    

    【讨论】:

    • 现在我添加 header("Content-Type: application/json;charset=UTF-8");但直到我没有得到解决方案。我的服务器上也出现了同样的结果。但它在我的本地主机上工作。
    • 在你设置标题的地方显示你的 php 代码,尝试省略 ;charset=UTF-8 并查看
    • 我在 config.php 中使用这个 set_charset("utf8"); $conn = new mysqli("localhost", "usename", "password", "db") ; ?>
    • 不要在这里贴密码,返回的db结果json_encode()在哪里
    • 我在另一个 php 文件中使用了 json_encode()。上面的文件是 config.php
    猜你喜欢
    • 2012-07-11
    • 2013-05-16
    • 2023-03-14
    • 2011-08-09
    • 2013-10-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多