且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

检测 PHP 中的请求类型(GET、POST、PUT 或 DELETE)

更新时间:2022-03-11 01:05:08

通过使用

$_SERVER['REQUEST_METHOD']

示例

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
     // The request is using the POST method
}

有关更多详细信息,请参阅 $_SERVER 变量的文档.

For more details please see the documentation for the $_SERVER variable.