0
0
PHPprogramming~20 mins

PHP error types and levels - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
PHP Error Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2: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;
?>
AWarning: Undefined variable: undefinedVar in /path/to/script.php on line 6
BFatal error: Undefined variable: undefinedVar in /path/to/script.php on line 6
CNotice: Undefined variable: undefinedVar in /path/to/script.php on line 6
DNo output, script runs silently
Attempts:
2 left
💡 Hint
Undefined variables trigger notices, not warnings or fatal errors.
Predict Output
intermediate
2: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;
?>
AParse error: Division by zero
BWarning: Division by zero
CFatal error: Division by zero
DNotice: Division by zero
Attempts:
2 left
💡 Hint
Division by zero is a runtime warning, not a fatal error.
Predict Output
advanced
2:00remaining
What error does this PHP code produce?
What error message will this PHP code output?
PHP
<?php
// Call to undefined function
undefinedFunction();
?>
AParse error: Call to undefined function undefinedFunction()
BWarning: Call to undefined function undefinedFunction()
CNotice: Call to undefined function undefinedFunction()
DFatal error: Uncaught Error: Call to undefined function undefinedFunction()
Attempts:
2 left
💡 Hint
Calling a function that does not exist causes a fatal error.
Predict Output
advanced
2: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');
?>
AWarning: include(missingfile.php): failed to open stream
BFatal error: include(missingfile.php): failed to open stream
CNotice: include(missingfile.php): failed to open stream
DParse error: include(missingfile.php): failed to open stream
Attempts:
2 left
💡 Hint
include() triggers a warning if the file is missing, but script continues.
Predict Output
expert
3: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();
?>
AFatal error: Uncaught Error: Call to undefined function undefinedFunc()
B
Notice: Undefined variable: var
Warning: include(nofile.php): failed to open stream
CNo output, all errors suppressed
D
Warning: include(nofile.php): failed to open stream
Fatal error: Uncaught Error: Call to undefined function undefinedFunc()
Attempts:
2 left
💡 Hint
Only E_ERROR and E_PARSE are reported; notices and warnings are ignored.