PHP code example of dmitry-suffi / error-handler

1. Go to this page and download the library: Download dmitry-suffi/error-handler library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dmitry-suffi / error-handler example snippets



$handler = new \suffi\ErrorHandler\ErrorHandler();

set_error_handler([$handler, 'errorHandler']);
set_exception_handler([$handler, 'exceptionHandler']);



$handler->debug = true;



$handler->writeLog = true;

$handler->logger = $logger;



$handler->$debugLog = true;


    //Page with an error message
    protected function htmlError(string $errstr)
    {
        return $errstr;
    }

    //Report an error for ajax-request
    protected function jsonError(string $errstr)
    {
        return json_encode(['error' => $errstr]);
    }