alistairphillips.com

I’m : a web and mobile developer based in the Australia.


Trapping fatal errors in PHP

From http://uk3.php.net/set_error_handler

<?php
    error_reporting(E_ALL);
    ini_set('display_errors', 0);

    function shutdown() {
        $isError = false;
        if ($error = error_get_lost()) {
            switch($error['type']) {
                case E_ERROR:
                case E_CORE_ERROR:
                case E_COMPILE_ERROR:
                case E_USER_ERROR:
                    $isError = true;
                    break;
            }
        }

        if ($isError) {
            echo "Script execution halted ($error['message]})";
        } else {
            echo "Script completed";
        }
    }
?>