php://input 通过POST用希伯来语检索JSON,返回问号

php://input 通过POST用希伯来语检索JSON,返回问号,php,json,post,php-stream-wrappers,Php,Json,Post,Php Stream Wrappers,我使用PHP脚本检索通过POST发送的JSON对象 JSON POST请求基本上如下所示: POST /script.php HTTP/1.1 Host: xx.xx.xx.xx Content-Type: application/json Content-Length: xx Connection: keep-alive {var:"value", var2:"value2", etc..} $content = file_get_contents('php://input'); file

我使用PHP脚本检索通过POST发送的JSON对象

JSON POST请求基本上如下所示:

POST /script.php HTTP/1.1
Host: xx.xx.xx.xx
Content-Type: application/json
Content-Length: xx
Connection: keep-alive

{var:"value", var2:"value2", etc..}
$content = file_get_contents('php://input');
file_put_contents("check.log", $content);
$data = json_decode($content, true);
{var:"?????",var2:"??????",..}
PHP服务器端代码如下:

POST /script.php HTTP/1.1
Host: xx.xx.xx.xx
Content-Type: application/json
Content-Length: xx
Connection: keep-alive

{var:"value", var2:"value2", etc..}
$content = file_get_contents('php://input');
file_put_contents("check.log", $content);
$data = json_decode($content, true);
{var:"?????",var2:"??????",..}
我故意想将接收到的内容保存到一个文件(check.log)中,这样我就可以按原样检查接收到的原始输入

我的问题是,当JSON在“value”、“value2”等位置包含希伯来文字符时。。它们在保存的文件check.log中作为问号(????)接收(我通过十六进制编辑器checkd check.log。它们是问号.0x3F),因此收到的“check.log”文件如下所示:

POST /script.php HTTP/1.1
Host: xx.xx.xx.xx
Content-Type: application/json
Content-Length: xx
Connection: keep-alive

{var:"value", var2:"value2", etc..}
$content = file_get_contents('php://input');
file_put_contents("check.log", $content);
$data = json_decode($content, true);
{var:"?????",var2:"??????",..}
如果它对任何人都有帮助的话,我正在使用Apache2.2.3服务器和PHP5

这是PHP的内部编码设置的问题吗php://input 包装纸


是否还有其他方法可以解决此问题?

您的标题包含集合

header('Content-Type: application/json; Charset=UTF-8');

//对从服务器接收到的数据进行编码

$json = utf8_encode($content);
$data = json_decode($content, true);
可能是这样的: