Challenge - 5 Problems
PHP Error Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this PHP code with error reporting?
Consider the following PHP code snippet. What will be the output when run with error reporting set to E_ALL?
PHP
<?php error_reporting(E_ALL); ini_set('display_errors', 1); // Undefined variable usage echo $undefinedVar; ?>
Attempts:
2 left
💡 Hint
Undefined variables trigger notices, not warnings or fatal errors.
✗ Incorrect
In PHP, accessing an undefined variable triggers a Notice level error, not a Warning or Fatal error. With E_ALL reporting enabled, this Notice is displayed.
❓ Predict Output
intermediate2:00remaining
What error level is triggered by this PHP code?
What type of error does the following PHP code produce?
PHP
<?php // Division by zero $result = 10 / 0; ?>
Attempts:
2 left
💡 Hint
Division by zero is a runtime warning, not a fatal error.
✗ Incorrect
Dividing by zero in PHP triggers a Warning level error, allowing the script to continue running.
❓ Predict Output
advanced2:00remaining
What error does this PHP code produce?
What error message will this PHP code output?
PHP
<?php
// Call to undefined function
undefinedFunction();
?>Attempts:
2 left
💡 Hint
Calling a function that does not exist causes a fatal error.
✗ Incorrect
In PHP 7+, calling an undefined function triggers a fatal error (Error exception), stopping script execution.
❓ Predict Output
advanced2:00remaining
What error level is triggered by this PHP code?
What error level does this PHP code produce?
PHP
<?php // Including a non-existent file include('missingfile.php'); ?>
Attempts:
2 left
💡 Hint
include() triggers a warning if the file is missing, but script continues.
✗ Incorrect
The include statement triggers a Warning if the file is missing, allowing the script to continue. require() would cause a fatal error.
❓ Predict Output
expert3:00remaining
What is the output of this PHP error handling code?
What will be the output of this PHP code snippet?
PHP
<?php error_reporting(E_ERROR | E_PARSE); ini_set('display_errors', 1); // Trigger notice echo $var; // Trigger warning include('nofile.php'); // Trigger fatal error undefinedFunc(); ?>
Attempts:
2 left
💡 Hint
Only E_ERROR and E_PARSE are reported; notices and warnings are ignored.
✗ Incorrect
With error_reporting set to E_ERROR | E_PARSE, notices and warnings are not shown. The fatal error from calling undefinedFunc() is displayed.