Bird
0
0

Identify the error in this PHP code:

medium📝 Debug Q6 of 15
PHP - Error and Exception Handling
Identify the error in this PHP code:
<?php
error_reporting(E_ALL);
trigger_error('Custom error', E_USER_ERROR)
echo 'End';
?>
AIncorrect error type E_USER_ERROR used
BMissing semicolon after trigger_error statement
Cerror_reporting should be set to E_ERROR only
Decho statement should come before trigger_error
Step-by-Step Solution
Solution:
  1. Step 1: Check syntax of trigger_error line

    Missing semicolon at end of trigger_error line causes syntax error.
  2. Step 2: Validate other statements

    E_USER_ERROR is valid, error_reporting is fine, echo can come after error trigger.
  3. Final Answer:

    Missing semicolon after trigger_error statement -> Option B
  4. Quick Check:

    Syntax error due to missing semicolon [OK]
Quick Trick: Always end PHP statements with semicolon [OK]
Common Mistakes:
  • Forgetting semicolon
  • Misusing error types
  • Wrong order of statements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes