Câu hỏi phỏng vấn PHP
Câu hỏi

Explain the Exception Hie...

Câu trả lời

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

senior

Gợi ý câu hỏi phỏng vấn

middle

Differentiate between exception and error

junior

What is the difference between var_dump() and print_r() ?

junior

Explain what the different PHP errors are

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào