PHP snippet for extra debugging

<?php

// Debug - Add this on top of your index.php file

ini_set('error_reporting', E_ERROR);
register_shutdown_function("fatal_handler");
function fatal_handler() {
    $error = error_get_last();
    echo("");
    print_r($error);
}

?>

If you've ever struggled to get your CMS like WordPress, Joomla, Magento or website display any errors, you will definitely find this snippet helpful.

I personally use this a lot and I would like to share this with more people.

Usage: Add this on top of your index.php file or the file that is not displaying any errors:

// Debug - Add this on top of your index.php file

ini_set('error_reporting', E_ERROR);
register_shutdown_function("fatal_handler");
function fatal_handler() {
    $error = error_get_last();
    echo("");
    print_r($error);
}

Some CMSs come with built in debug mode, but in case your CMS doesn't offer that out of the box, you could simply use this snippet - it has helped me a lot!

BETA Snippet explanation automatically generated by OpenAI:

No explanation generated yet.

Snippet By Dev Dojo

·

Created June 12th, 2021

·

Report Snippet