Bird
0
0

What is the problem with this PHP code snippet?

medium📝 Debug Q7 of 15
PHP - Error and Exception Handling
What is the problem with this PHP code snippet?
<?php
error_reporting(E_ALL);
trigger_error('Deprecated feature', E_DEPRECATED);
trigger_error('User notice', E_USER_NOTICE);
?>
ANo problem; code runs and reports both errors
Btrigger_error cannot be used with E_DEPRECATED
CE_DEPRECATED is not a valid error level
DE_USER_NOTICE should be used instead of E_USER_ERROR
Step-by-Step Solution
Solution:
  1. Step 1: Check validity of error levels

    E_DEPRECATED and E_USER_NOTICE are valid error levels for trigger_error.
  2. Step 2: Confirm error_reporting setting

    E_ALL includes all error levels, so both errors will be reported.
  3. Final Answer:

    No problem; code runs and reports both errors -> Option A
  4. Quick Check:

    Valid error levels and reporting enabled [OK]
Quick Trick: E_DEPRECATED and E_USER_NOTICE are valid with trigger_error [OK]
Common Mistakes:
  • Thinking E_DEPRECATED is invalid
  • Confusing user error levels
  • Assuming trigger_error only accepts certain levels

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes