您可能需要直接从php://输入流中读取数据。
我knwo这是你必须做这个PUT请求,一些快速的谷歌搜索表示该方法适用于DELETE以及。
参见here和here的例子。评论here说这个方法也适用于DELETE。
这是一个有趣的代码示例,将有助于(从简单的symfony 1.4.9框架的sfWebRequest.class.php轻微改变):
public function initialize(...)
{
... code ...
$request_vars = array();
if (isset($_SERVER['REQUEST_METHOD']))
{
switch ($_SERVER['REQUEST_METHOD'])
{
case 'PUT':
if ('application/x-www-form-urlencoded' === $this->getContentType())
{
parse_str($this->getContent(), $request_vars );
}
break;
case 'DELETE':
if ('application/x-www-form-urlencoded' === $this->getContentType())
{
parse_str($this->getContent(), $request_vars );
}
break;
}
... more code ...
}
public function getContent()
{
if (null === $this->content)
{
if (0 === strlen(trim($this->content = file_get_contents('php://input'))))
{
$this->content = false;
}
}
return $this->content;
}
该代码示例将PUT或DELETE请求参数放入$ request_vars数组中。一个限制似乎是表单(如果您正在使用另一个内容类型的头文件)必须是“application / x-www-form-urlencoded”,一些快速的搜索会确认这一点。