Yaf_Request_Abstract::getMethod

(Yaf >=1.0.0)

Yaf_Request_Abstract::getMethod检索请求方法

说明

public function Yaf_Request_Abstract::getMethod(): ?string

检索请求方法

参数

此函数没有参数。

返回值

请求方法,以字符串形式表示,例如 GET、POST、PUT、DELETE。

示例

示例 #1 Yaf_Request_Abstract::getMethod() 示例

<?php
class OrderController extends Yaf_Controller_Abstract
{
    public function saveAction()
    {
        $request = $this->getRequest();

        // 假设请求是通过 POST /order/save 发送的
        var_dump($request->getMethod());
    }
}
?>

以上示例的输出类似于:

string(4) "POST"

参见