Skip to content
PHP Ecosystem
Explore

ForbiddenHttpException

API reference › yii › web › ForbiddenHttpException

classyii\web\ForbiddenHttpException
ExtendsHttpException » yii\base\UserException » yii\base\Exception » Exception
Since2.0
Sourceframework/web/ForbiddenHttpException.php

ForbiddenHttpException represents a “Forbidden” HTTP exception with status code 403.

Use this exception when a user is not allowed to perform the requested action. Using different credentials might or might not allow performing the requested action. If you do not want to expose authorization information to the user, it is valid to respond with a 404 NotFoundHttpException.

See also: https://tools.ietf.org/html/rfc7231#section-6.5.3.

PropertyTypeDescriptionDefined by
$statusCodeintHTTP status code, such as 403, 404, 500, etc. Default: null.HttpException
MethodDescriptionDefined by
__construct()Constructor.ForbiddenHttpException
getName()HttpException
public function __construct(string|null $message = null, int $code = 0, Throwable|null $previous = null)

Constructor.

Parameters

ParameterTypeDescription
$messagestring|nullError message
$codeintError code
$previousThrowable|nullThe previous exception used for the exception chaining.