本文介绍了PHP获取PATCH请求数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要向 PHP 应用程序发出 PATCH
请求.
I need to make a PATCH
request to a PHP application.
如何从该应用程序内的 PATCH
请求中获取数据?
How can I get the data from that PATCH
request inside that application?
如果我必须使用 POST
来完成,那只是对全局 $_POST
变量的简单访问.
If I had to do it with a POST
, it would just be a simple access to the global $_POST
variable.
推荐答案
您可以通过 php://input
流包装器:
You can get data with php://input
stream wrapper:
$data = file_get_contents('php://input');
还要确保您的 Web 服务器支持 PATCH 请求,有些配置为仅响应 GET 和 POST.
Also make sure your web server supports PATCH requests, some are configured to respond only to GET and POST.
这篇关于PHP获取PATCH请求数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!