检测PHP中的请求类型(GET、POST、PUT或DELETE)如何检测PHP中使用了哪种请求类型(GET、POST、PUT或DELETE)?
3 回答
HUH函数
TA贡献1836条经验 获得超4个赞
$_SERVER['REQUEST_METHOD']
例
if ($_SERVER['REQUEST_METHOD'] === 'POST') { // The request is using the POST method}
慕容森
TA贡献1853条经验 获得超18个赞
REQUEST METHOD
$method = $_SERVER['REQUEST_METHOD']if ($method == 'POST') { // Method is POST} elseif ($method == 'GET') { // Method is GET} elseif ($method == 'PUT') { // Method is PUT} elseif ($method == 'DELETE') { // Method is DELETE} else { // Method unknown}
switch
if-else
GET
POST
<!-- DELETE method --><form action='' method='POST'> <input type="hidden" name'_METHOD' value="DELETE"></form><!-- PUT method --><form action='' method='POST'> <input type="hidden" name'_METHOD' value="PUT"></form>
- 3 回答
- 0 关注
- 1974 浏览
相关问题推荐
添加回答
举报
0/150
提交
取消