Explain the Exception Hie...
Explain the Exception Hie...
In PHP 7, the Exception hierarchy was updated with the introduction of the Error
class. Here's an explanation of the key differences between Error
and ErrorException
:
Error
is a new base class introduced in PHP 7 that represents internal PHP errors, such as parsing errors or type errors. It is used for all fatal errors that cannot be recovered from[1].
ErrorException
is a subclass of Exception
that allows PHP errors to be handled like exceptions. It has existed since PHP 5.1[1].
The main difference is that Error
is used for internal PHP errors, while ErrorException
is used for converting PHP errors to exceptions[1].
Error
has a $severity
property that ErrorException
lacks. This property indicates the severity level of the error[1].
You should use Error
to catch all internal PHP errors, but not for your own custom exceptions. For custom...
senior
Gợi ý câu hỏi phỏng vấn
Chưa có bình luận nào