Bird
0
0

What will be the output of this PHP code?

medium📝 Predict Output Q13 of 15
PHP - Error and Exception Handling
What will be the output of this PHP code?
<?php
error_reporting(E_ERROR | E_WARNING);
echo $undefined_variable;
include('missing_file.php');
?>
AWarning about missing file only
BFatal error about missing file
CNotice about undefined variable and warning about missing file
DNo output, script runs silently
Step-by-Step Solution
Solution:
  1. Step 1: Check error_reporting level

    Only E_ERROR and E_WARNING are reported; notices are not shown.
  2. Step 2: Analyze code behavior

    Undefined variable triggers a notice (not shown). Missing file triggers a warning (shown).
  3. Final Answer:

    Warning about missing file only -> Option A
  4. Quick Check:

    E_WARNING shown, notices hidden [OK]
Quick Trick: Only errors and warnings show; notices are hidden [OK]
Common Mistakes:
  • Expecting notice output when it's excluded
  • Confusing warning with fatal error
  • Thinking script stops on warning

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PHP Quizzes