public
Created

Error Reporting

  • Download Gist
errrep.php
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
<?php
 
error_reporting(0);
 
set_error_handler('custHandler');
register_shutdown_function('shutdownHandler');
 
function custHandler($errno, $errstr, $errfile, $errline, $errcontext)
{
echo "Custom handler called.";
}
 
function shutdownHandler()
{
echo "I died.";
var_dump(error_get_last());
}
 
$data = '';
while(true) {
$data .= str_repeat('#', PHP_INT_MAX);
}

php fatal.php
I died.array(4) {
["type"]=>
int(1)
["message"]=>
string(78) "Out of memory (allocated 786432) (tried to allocate 9223372036854775808 bytes)"
["file"]=>
string(40) "/home/alex/Documents/Code/test/fatal.php"
["line"]=>
int(21)
}

Removing the error_reporting line and changing display_errors to 0 in php.ini yields the same results.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.