What is the Exception restriction in PHP?

I saw this code in the PHP documentation :

try {
throw new ErrorException("Exception message", 0, E_USER_ERROR);
} catch(ErrorException $e) {
echo "This exception severity is: " . $e->getSeverity();
var_dump($e->getSeverity() === E_USER_ERROR);
}

And he continues:

This exception severity is: 256
bool(true)

What does the severity of the exception mean, and should I use it at all?

+4
source share
1 answer

$severityis an integer representing, well, the severity of the error. The manual states that it can be any integer, but it is preferable to use a constant from the predefined error constants . They are equally used by error_reporting .

, ErrorException Exception, $severity. , ErrorException PHP Exception s. set_error_handler().

, ErrorException::$severity PHP, , Exception.. , , ErrorException , .

+2

Source: https://habr.com/ru/post/1685710/


All Articles