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

Maximum how many arguments are allowed in a function in PHP?

senior

Store an array as JSON or as a PHP serialized array?

junior

How is it possible to set an infinite execution time for PHP script?

Bình luận

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

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