php - How not to display the error stack when catching fatal errors -
i set set_exception_handler , set_error_handler handle exceptions , errors, still not catch 'fatal error'.
i tried this:
register_shutdown_function( "fatal_handler" ); function fatal_handler() { flashmessages::flashit( 'message', 'fatal error' ); include( settings::abspath . '/src/views/message.php' ); $error = error_get_last(); if ( $error !== null ) { $errno = $error[ "type" ]; $errfile = $error[ "file" ]; $errline = $error[ "line" ]; $errstr = $error[ "message" ]; var_dump( $error ); } }
and i'm indeed able dump error, there no way avoid full stack error on top of page. how avoid displaying error stack ?
register_shutdown_function( "fatal_handler" ); function fatal_handler() { $error = error_get_last(); if ( $error[ "type" ] == 1) { //only fatal errors $errno = $error[ "type" ]; $errfile = $error[ "file" ]; $errline = $error[ "line" ]; $errstr = $error[ "message" ]; flashmessages::flashit("'$errstr' in $errfile in line $errline ", 'fatal error'); include( settings::abspath . '/src/views/message.php' ); } }
and dont show errors in production outputted php.
ini_set('display_errors', 0); ini_set('display_startup_errors', 0);
Comments
Post a Comment