🎤 PHP Error Handling – Viva Questions
🟢 Basic Viva Questions
- What is error handling in PHP?
- Why is error handling important?
- Name different types of errors in PHP.
- What is a fatal error?
- What is a warning in PHP?
- What is a notice?
- What is a parse error?
- What is
error_reporting()? - How do you enable error display in PHP?
- How do you disable error display?
🟡 Conceptual Questions
- What is the difference between error and exception?
- What is exception handling?
- What are
try,catch, andthrow? - Can we use multiple catch blocks?
- What is
Throwablein PHP? - What happens if an exception is not caught?
- What is the use of
finallyblock? - What is a custom error handler?
- What is
set_error_handler()? - What is
trigger_error()?
🔵 Practical Viva Questions
- How will you handle division by zero error?
- How do you debug PHP code?
- What is
var_dump()used for? - Difference between
echoandprint_r()for debugging? - How do you log errors in PHP?
- Where are PHP error logs stored?
- What is
error_log()? - How do you handle database connection errors?
- What happens when you use an undefined variable?
- How do you fix a white screen error?
🔴 Tricky / Advanced Viva Questions
- Can PHP handle fatal errors? How?
- What is
register_shutdown_function()? - Can we convert errors into exceptions?
- What is
ErrorException? - What is stack trace?
- What is the difference between
die()andexit()? - Can we continue execution after
die()? - What is the difference between
includeandrequireerrors? - What happens if you divide a number by zero in PHP 8?
- Why should errors not be shown in production?
🎯 Scenario-Based Viva
- Your website shows a blank page. What will you do?
- A user sees raw PHP error messages. Is it good? Why?
- API is failing. How will you debug it?
- Database connection failed. How will you handle it?
- 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.”






