PHP show all errors - Displaying All Errors to Ensure Code Quality

PHP show all errors - Displaying All Errors to Ensure Code Quality

Explore methods to display all errors in PHP, specifically php show all errors, so that you can efficiently troubleshoot, ensuring your PHP code meets high-quality standards and functions as expected.

What is display_errors

While developing a website with PHP, encountering errors is inevitable, and sometimes it can lead to the program not functioning correctly. In this article, P2PTuts will share with you a more detailed approach to displaying errors (php show all error) and warnings in PHP files.

Enabling display_errors

During the process of constructing a website with PHP, encountering errors is a common occurrence. Therefore, P2PTuts wants to share with you how to display error and warning messages in your PHP source code.

// Activate error and warning display
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);

// Set the error display level

// Display syntax errors during compilation
ini_set('display_errors', 'on');

// Constants related to the error display level
error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
// Display all types of errors
// error_reporting(E_ALL);

// Display only serious errors (ignore warnings and notices)
// error_reporting(E_ERROR);

// Display only serious errors and warnings
// error_reporting(E_ERROR | E_WARNING);

// Display all types of errors including syntax errors
// error_reporting(E_ALL | E_PARSE);

One of the simplest methods to display all errors and warnings is to add the following lines of code at the beginning of your PHP file:

The ini_set function will attempt to override the error configuration in the php.ini file in case display_error is turned off, and it activates it directly in the source code. error_reporting() is an important PHP function used to display errors. You can pass different parameters to display PHP errors at a certain level.

In the example above, we pass E_ALL, meaning it displays all types of errors. However, you can choose different parameters for different error levels:

  • E_ERROR: Serious runtime errors that halt execution.
  • E_WARNING: Non-serious warnings; the program continues execution.
  • E_PARSE: Syntax parsing errors during compilation; serious errors.
  • E_NOTICE: Non-serious information messages.
  • E_ALL: Displays all types of errors.

You can combine constants using the bitwise OR operator (|). For example, E_ERROR | E_WARNING will display both serious errors and warnings. If you want to display all types of errors, you can use E_ALL. Choose constants that fit your specific needs.

However, the above code does not display syntax errors such as missing commas or parentheses. To display these errors, you need to set the display_errors attribute in the php.ini file:

display_errors = on

The display_errors attribute must have the value "on" in the php.ini configuration file. This will display all types of errors, including syntax errors and errors that cannot be displayed using ini_set in regular PHP source code.


This guide helps you display error and warning messages in your PHP source code. However, you can also reverse it to turn off error messages when necessary. Good luck!

Keywords: Show error PHP, Error_reporting, Php not showing errors, Ubuntu apache show php errors, Error_reporting() in PHP, Php show error 500, Check error PHP,  Turn off display errors PHP