Detecting request type in PHP (GET, POST, PUT or DELETE)

前端 未结 13 1724
不思量自难忘°
不思量自难忘° 2020-11-22 08:02

How can I detect which request type was used (GET, POST, PUT or DELETE) in PHP?

13条回答
  •  南旧
    南旧 (楼主)
    2020-11-22 08:14

    It is valuable to additionally note, that PHP will populate all the $_GET parameters even when you send a proper request of other type.

    Methods in above replies are completely correct, however if you want to additionaly check for GET parameters while handling POST, DELETE, PUT, etc. request, you need to check the size of $_GET array.

提交回复
热议问题