0 追蹤者

類別 yii\web\MethodNotAllowedHttpException

繼承關係yii\web\MethodNotAllowedHttpException » yii\web\HttpException » yii\base\UserException » yii\base\Exception » Exception
自版本起可用2.0
原始碼 https://github.com/yiisoft/yii2/blob/master/framework/web/MethodNotAllowedHttpException.php

MethodNotAllowedHttpException 代表狀態碼為 405 的 "不允許的方法" HTTP 例外。

另請參閱 https://tools.ietf.org/html/rfc7231#section-6.5.5

公開屬性

隱藏繼承的屬性

屬性 類型 描述 定義於
$statusCode integer HTTP 狀態碼,例如 403、404、500 等。 yii\web\HttpException

方法詳情

隱藏繼承的方法

__construct() 公開方法

建構子。

public void __construct ( $message null, $code 0, $previous null )
$message string|null

錯誤訊息

$code integer

錯誤代碼

$previous Throwable|null

用於例外鏈結的前一個例外。

                public function __construct($message = null, $code = 0, $previous = null)
{
    parent::__construct(405, $message, $code, $previous);
}

            
getName() 公開方法
public string getName ( )
return string

此例外的使用者友善名稱

                public function getName()
{
    if (isset(Response::$httpStatuses[$this->statusCode])) {
        return Response::$httpStatuses[$this->statusCode];
    }
    return 'Error';
}