Exam 200-710 All QuestionsBrowse all questions from this exam
Question 35

True or false: you can catch fatal errors (e.g., parse errors, out of memory errors, compilation errors) in PHP 7 using try/catch.

    Correct Answer: A

    Starting from PHP 7, you can catch fatal errors such as parse errors, out of memory errors, and compilation errors using try/catch blocks. This is done by catching instances of the Error class, which represents fatal errors. This change was introduced to provide better error handling mechanisms and more control over error management in PHP.

Discussion
[Removed]Option: A

in PHP 7.x and 8.x, now it's possible to catch Fatar errors.. So the answer should be "True". Example : try { someNoneExistentFunction(); } catch (Error $e) { echo "There is an Error caught here: " . $e->getMessage(); } Output for 7.x There is an Error caught here: Call to undefined function someNoneExistentFunction() Output for 5.x : Fatal error: Call to undefined function someNoneExistentFunction()