Viva (oral exam) questions on PHP Error Handling

🎤 PHP Error Handling – Viva Questions

🟢 Basic Viva Questions

  1. What is error handling in PHP?
  2. Why is error handling important?
  3. Name different types of errors in PHP.
  4. What is a fatal error?
  5. What is a warning in PHP?
  6. What is a notice?
  7. What is a parse error?
  8. What is error_reporting()?
  9. How do you enable error display in PHP?
  10. How do you disable error display?

🟡 Conceptual Questions

  1. What is the difference between error and exception?
  2. What is exception handling?
  3. What are try, catch, and throw?
  4. Can we use multiple catch blocks?
  5. What is Throwable in PHP?
  6. What happens if an exception is not caught?
  7. What is the use of finally block?
  8. What is a custom error handler?
  9. What is set_error_handler()?
  10. What is trigger_error()?

🔵 Practical Viva Questions

  1. How will you handle division by zero error?
  2. How do you debug PHP code?
  3. What is var_dump() used for?
  4. Difference between echo and print_r() for debugging?
  5. How do you log errors in PHP?
  6. Where are PHP error logs stored?
  7. What is error_log()?
  8. How do you handle database connection errors?
  9. What happens when you use an undefined variable?
  10. How do you fix a white screen error?

🔴 Tricky / Advanced Viva Questions

  1. Can PHP handle fatal errors? How?
  2. What is register_shutdown_function()?
  3. Can we convert errors into exceptions?
  4. What is ErrorException?
  5. What is stack trace?
  6. What is the difference between die() and exit()?
  7. Can we continue execution after die()?
  8. What is the difference between include and require errors?
  9. What happens if you divide a number by zero in PHP 8?
  10. Why should errors not be shown in production?

🎯 Scenario-Based Viva

  1. Your website shows a blank page. What will you do?
  2. A user sees raw PHP error messages. Is it good? Why?
  3. API is failing. How will you debug it?
  4. Database connection failed. How will you handle it?
  5. You want to show a custom error page. How will you do it?

🧠 Quick Rapid-Fire (Teacher Favorite)

  • What is E_ALL?
  • What is E_WARNING?
  • What is E_NOTICE?
  • What is exception?
  • What is try-catch?
  • What is debugging?
  • What is logging?

🏆 Bonus Tip for Students

If stuck in viva, say:

“I will use try-catch for handling exceptions, enable error reporting during development, and log errors in production.”