Complete the code to display all errors except notices.
<?php
error_reporting([1]);
?>The error_reporting function sets which errors are reported. Using E_ALL & ~E_NOTICE reports all errors except notices.
Complete the code to trigger a user error with a custom message.
<?php
trigger_error([1], E_USER_ERROR);
?>The trigger_error function sends a user-generated error message. The first argument is the message string.
Fix the error in the code to set error reporting to show only warnings.
<?php
error_reporting([1]);
?>To report only warnings, use E_WARNING as the argument to error_reporting.
Fill both blanks to set error reporting to show all errors except deprecated and strict notices.
<?php error_reporting(E_ALL & ~[1] & ~[2]); ?>
Using bitwise AND with the negation of E_DEPRECATED and E_STRICT excludes these error types from reporting.
Fill all three blanks to create a custom error handler function that handles warnings and notices.
<?php function customErrorHandler([1], $errstr, $errfile, $errline) { if ($errNo & ([2] | [3])) { echo "Custom error: $errstr in $errfile on line $errline"; } } set_error_handler('customErrorHandler'); ?>
The error handler function receives the error number as the first argument. The condition checks if the error is a warning or notice using bitwise OR.