PHP
(quick examples)
DO NOT SHOW ERROR, SAVE TO LOG FILE error_reporting(E_ALL & ~E_NOTICE); ini_set("display_errors", 0); ini_set("log_errors", 1); ini_set("error_log", "error.log");
CATCH ALL - SHOW CUSTOM MESSAGE set_exception_handler(function($ex) { ?> <div style="position:fixed; top:0; left:0; z-index:9999; width:100vw; height:100vw; background:#fff"> <h1>AN ERROR HAS OCCURED.</h1> </div> <?php });
ERRORS TABLE date | DATETIME file | VARCHAR line | VARCHAR message | TEXT trace | TEXT
DO NOT SHOW & LOG ERRORS error_reporting(E_ALL & ~E_NOTICE); ini_set("display_errors", 0); ini_set("log_errors", 0);
CATCH ALL - SAVE ERROR TO DATABASE set_exception_handler(function($ex) { $pdo = new PDO("mysql:host=HOST; dbname=NAME;charset=utf8mb4", "USER", "PASSWORD"); $stmt = $pdo->prepare("INSERT INTO `errors` (`file`, `line`, `message`, `trace`) VALUES (?,?,?,?)"); $stmt->execute([$ex->getFile(), $ex->getLine(),$ex->getMessage(), $ex->getTraceAsString()]); });