Symfony 7 – PHP – Exception and Error Handling

20 multiple-choice questions about PHP exceptions, errors, try/catch/finally, Throwable hierarchy, and good practices for handling failures.


Question 1: What is the purpose of exceptions in PHP?

Question 2: What base interface do all exceptions and errors implement in PHP 7+?

Question 3: What happens when an exception is not caught?

Question 4: Which keyword is used to handle exceptions?

Question 5: Which block always executes, whether an exception is thrown or not?

Question 6: Which class is the base of all user-defined exceptions?

Question 7: What does this code print?\ntry { throw new Exception("Oops"); } catch (Exception $e) { echo $e->getMessage(); }

Question 8: What does "Error" represent in PHP 7+?

Question 9: Can you catch both Exception and Error together?

Question 10: What happens if you throw something that is not a Throwable?

Question 11: What is the correct order of try/catch/finally blocks?

Question 12: Which method retrieves the error message from an Exception object?

Question 13: What is the effect of rethrowing an exception inside a catch block?

Question 14: What’s the purpose of the ErrorException class?

Question 15: What function allows setting a global handler for uncaught exceptions?

Question 16: What’s the main difference between Exception and Error in PHP 7+?

Question 17: What happens if a finally block has a return statement?

Question 18: How can PHP errors like E_WARNING be converted into exceptions?

Question 19: Which statement is true about multiple catch blocks?

Question 20: What’s the best practice when catching exceptions broadly (Throwable)?