【发布时间】:2017-03-16 21:46:04
【问题描述】:
我以前使用 file_get_contents 来检索这样的 JSON 文档:
$json = file_get_contents('php://input');
但是当尝试向 json 添加特殊字符(例如 ÷)时... file_get_contents 显然将其解码为 ASCII 而不是 UTF8,因此 ÷ 符号被转换为 u00f7。
我可以强制 file_get_contents 将 php://input 文档解码为 UTF8 吗?或者我还能做些什么,比如以某种方式将文档作为二进制文件提取出来,然后自己手动解码?
【问题讨论】:
-
尝试使用 utf8 添加标题内容类型
标签: php json file-get-contents decoding