PHP to show All errors

Here is the top answer to show all errors in PHP

ini_set(‘display_errors’, 1);
ini_set(‘display_startup_errors’, 1);

error_reporting function in php

The error_reporting() function sets the error_reporting directive at runtime. PHP has many levels of errors, using this function sets that level for the duration (runtime) of your script. If the optional error_level is not set, error_reporting() will just return the current error reporting level

Example of error_reporting in php


// Turn off all error reporting

// Report simple running errors
error_reporting(E_ERROR | E_WARNING | E_PARSE);

// Reporting E_NOTICE can be good too (to report uninitialized
// variables or catch variable name misspellings ...)
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);

// Report all errors except E_NOTICE
error_reporting(E_ALL & ~E_NOTICE);

// Report all PHP errors

// Report all PHP errors

// Same as error_reporting(E_ALL);
ini_set('error_reporting', E_ALL);


ini_set function in php

ini_set(string $option, string $value): string|false

Sets the value of the given configuration option. The configuration option will keep this new value during the script’s execution, and will be restored at the script’s ending.

Example of ini_set in php

echo ini_get('display_errors');

if (!ini_get('display_errors')) {
    ini_set('display_errors', '1');

echo ini_get('display_errors');

Leave a Comment