PHP://输入返回空 [英] php://input returns empty

查看:162
本文介绍了PHP://输入返回空的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有骨气的应用。当模型更新PUT请求发送到我的服务器。

I have Backbone application. When model updates PUT request goes to my server.

客户端看起来不错。但是在服务器端(PHP)我有一些麻烦。当我第一次测试中PHPStorm这一要求:

Client-side looks good. But on the server side (PHP) I have some trouble. When I first time test this request in PHPStorm:

file_get_contents('php://input')

返回我的期望。但在其他时候,它总是返回空。我重新启动Apache的 - 没有什么帮助。

return what I expect. But on the other times it always return empty. I restarted Apache - nothing helps.

我知道

请注意:甲流用PHP打开://输入只能读取一次;

Note: A stream opened with php://input can only be read once;

但我鑫卡特意味着一个接请求。每个生命不是一次:)哪里是我的错?

But I thinked that mean one by request. Not once per life :) Where is my mistake?

推荐答案

这是Kohana的问题。在Kohana_Request类有一块code,已经开通的PHP://输入流

It was Kohana problem. In Kohana_Request class there is piece of code, that already opened php://input stream

if ($method !== HTTP_Request::GET)
{
    // Ensure the raw body is saved for future use
    $body = file_get_contents('php://input');
}

这篇关于PHP://输入返回空的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆