PHP

HOW TO CATCH ALL ERRORS IN PHP

ERROR REPORTING LEVEL error_reporting(E_ALL); ERROR LOG (IF YOU WANT) ini_set("log_errors", 1); ini_set("error_log", "error.log");

PHP ERROR HANDLING (A)

01

PHP ERROR HANDLING (B)

02

SHOW ERRORS ini_set("display_errors", 1);    CUSTOM ERROR HANDLER (USE THIS TO CATCH ALL ERRORS) set_exception_handler(   function ($ex) { print_r($ex); } );

ERROR SETTINGS - DO NOT DISPLAY ERROR BUT KEEP LOG error_reporting(E_ALL); ini_set("log_errors", 1); ini_set("error_log", "error.log"); ini_set("display_errors", 0);

SHOW CUSTOM ERROR SCREEN (A)

03

SHOW CUSTOM ERROR SCREEN (B)

04

SHOW CUSTOM SCREEN ON ERROR set_exception_handler( function ($ex) { ?> <div style="position:fixed; top:0; left:0;    z-index:9999; width:100vw;    height:100vw; padding:10px;   background:#fff">   <h1>AN RROR HAS OCCURED.</h1>   <p>Fixing it now.</p>  </div> <?php });