📲 Download Utility Tools Apps

EMI Calculator

Download EMI Calculator

SOA Games

Download SOA Games

SOA Technology App

Download SOA Technology

BMI Checker

Download BMI Checker

Task Jira

Download Task Jira

Laughing Adda

Download Laughing Adda

📅 हिंदी कैलेंडर ऐप डाउनलोड करें

Download Shubhcalendar App

PHP Error Handling MCQ Test Paper (with Answers)

📝 PHP Error Handling – MCQ Test

📚 Section A: Basic (1 Mark Each)

1. Which function is used to report errors in PHP?
A) display_error()
B) error_reporting()
C) show_error()
D) report_error()
Answer: B


2. Which error type stops script execution?
A) Notice
B) Warning
C) Fatal Error
D) Deprecated
Answer: C


3. What does E_NOTICE indicate?
A) Critical error
B) Minor issue
C) Syntax error
D) Database error
Answer: B


4. Which function is used to display errors?
A) ini_set()
B) show_error()
C) print_error()
D) log_error()
Answer: A


5. What is the default behavior of warnings?
A) Stop script
B) Restart script
C) Continue execution
D) Delete file
Answer: C


📘 Section B: Intermediate (2 Marks Each)

6. Which block is used to handle exceptions?
A) if-else
B) try-catch
C) switch
D) loop
Answer: B


7. What keyword is used to throw an exception?
A) catch
B) throw
C) error
D) exception
Answer: B


8. Which class is used for exceptions in PHP?
A) Error
B) Exception
C) Throwable
D) Catch
Answer: B


9. What does Throwable represent?
A) Only errors
B) Only exceptions
C) Both errors and exceptions
D) None
Answer: C


10. What will happen if an exception is not caught?
A) Script continues
B) Script stops with error
C) Ignored
D) Page reloads
Answer: B


📙 Section C: Advanced (3 Marks Each)

11. Which function sets a custom error handler?
A) error_handler()
B) set_error_handler()
C) custom_error()
D) handle_error()
Answer: B


12. Which function generates a user-defined error?
A) user_error()
B) trigger_error()
C) throw_error()
D) error_create()
Answer: B


13. Which function logs errors to a file?
A) log_error()
B) error_log()
C) write_log()
D) file_log()
Answer: B


14. Which is used for debugging variables?
A) echo
B) print
C) var_dump()
D) show()
Answer: C


15. What is the purpose of finally block?
A) Catch error
B) Always execute code
C) Throw error
D) Stop script
Answer: B


🔥 Section D: Scenario-Based (4 Marks Each)

16. What will this code do?

echo 10/0;

A) Output 0
B) Fatal error
C) Warning/Error
D) Nothing
Answer: C


17. What is best practice in production?
A) Show errors
B) Hide errors and log them
C) Ignore errors
D) Stop execution
Answer: B


18. Which function handles fatal errors indirectly?
A) set_error_handler()
B) register_shutdown_function()
C) catch()
D) throw()
Answer: B


19. Which is better for database error handling?
A) echo
B) try-catch
C) print
D) die()
Answer: B


20. White screen of death means?
A) Syntax error
B) Hidden fatal error
C) Network issue
D) Browser crash
Answer: B


🏆 Score Guide

ScoreLevel
16–20Excellent 🔥
11–15Good 👍
6–10Average ⚠️
0–5Needs Improvement ❌


AI Spiritual Tools & Interactive Experiences

Explore powerful AI-driven tools for daily guidance, spirituality, fun quizzes, and self-discovery.

Today’s Quote

Get inspiring daily quotes powered by AI to motivate and guide your day.

Explore Now

AI Tarot Card Reader

Reveal insights about your future, love, and career with AI tarot readings.

Read Tarot

Love Match Calculator

Check compatibility and love predictions using AI-based analysis.

Check Match

Fortune Cookie

Open an AI fortune cookie and receive wisdom, luck, and fun messages.

Open Cookie

Quiz Categories

Engage with knowledge-based and fun quizzes across multiple categories.

Start Quiz

Panchang Calendar

View daily Panchang, auspicious timings, tithi, nakshatra, and festivals.

View Panchang

Online Numerology

Discover your destiny number, life path, and numerology predictions.

Calculate Now

Spiritual Feeds

Stay connected with spiritual thoughts, mantras, and divine content.

View Feeds

Quiz Hub

Attempt trending quizzes on GK, spirituality, festivals, and more.

Explore Quizzes