Change language

How do I get PHP errors to display?

There are four ways to display errors in PHP, which are listed below:
  • error_reporting:does not cancel E-STRICT, E-NOTICE and E_DEPRECATED errors and displays all other level errors.
  • display_errors:default value "off". Set it to on.
  • log_errors:The default is on, which specifies whether to log errors.
  • String error_log:specifies the name of the file where script errors should be logged.
Example:The fastest and easiest way to display errors in PHP is & # 8212 ; add the following lines to your code.
ini_set (’display_errors’, 1); ini_set (’display_startup_errors’, 1); error_reporting (E_ALL); 
  • ini_set: the ini_set function will try to override the configuration found in the PHP ini file.
  • display_errors: this is a directive which determines whether the error is displayed to the user or remains hidden.
  • display_startup_errors: is a directive that is used to find errors during the PHP startup sequence. The list of directives that can be overridden by the ini_set function is in the official documentation.
These two directives do not display parsing errors. Program 1: ini_set ( ’display_errors’ , 1); ini_set ( ’display_startup_errors’ , 1); error_reporting (E_ALL); include ( " gfg.php " ); ?> Output:
A warning will be shown- No such directory or file found in (location of file) with the specified line of error. 
To display errors, including parsing errors, you need to make the following changes to php.ini and restart php-fpm, apche2
display_errors = on 
Program 2:  
// Display number from 0 to 5 for ( $i = 0; $i < = 5 $i ++) // Semicolon after $i < = 5 missing { echo $i ; }
  • Output when display_error is disabled in php.ini:
  • Output when display_error is enabled and restarted:
The above directives will display any PHP errors that occurred when loading a website in a browser. Display errorsshould be disabled while the site is running to prevent any security when not in a development environment.


Best laptop for Sims 4


Best laptop for Zoom


Best laptop for Minecraft


Best laptop for engineering student


Best laptop for development


Best laptop for Cricut Maker


Best laptop for hacking


Best laptop for Machine Learning


Latest questions


psycopg2: insert multiple rows with one query

12 answers


How to convert Nonetype to int or string?

12 answers


How to specify multiple return types using type-hints

12 answers


Javascript Error: IPython is not defined in JupyterLab

12 answers


Python OpenCV | cv2.putText () method

numpy.arctan2 () in Python

Python | os.path.realpath () method

Python OpenCV | () method

Python OpenCV cv2.cvtColor () method

Python - Move item to the end of the list

time.perf_counter () function in Python

Check if one list is a subset of another in Python

Python os.path.join () method