Contact for Expert ServicesAdvertise with Ecomspark.

How to enable error reporting in PHP?

PHP is widely used web programming language. Sometimes when we run any php script and it’s shows nothing , a blank white screen. It means there is some problem in code. To know the error occurring, we have to enable error reporting.

There are various ways to enable error reporting in php. By default, most of the time error reporting is disabled on sever because we don’t want to show error message or other warnings to our users for worst user experience.

To display error messages caused by your PHP script you can include these lines of code:

ini_set('display_errors',1); 
 error_reporting(E_ALL);

Above code, will display errors in php code and will help in debugging code.

Another method is to do changes in php.ini file.  Below are the steps –

1- Find php.ini file, In xampp sever the php.ini (configuration file) file location is – /xampp/php/

php

2- Open the file in editor and find “Error handling and logging

phpError handling and logging-

3- To enable errors to display errors in browser remove (;) from

; display_errors = On; display_startup_errors = On

display-error-on
4- Restart the server to effect the changes done.

Following changes will enable error reporting in PHP files.

We can turn off error reporting for individual files by adding –

error_reporting(0);

If you don’t have access to php.ini on your sever then please contact to your web host they will assist you. 

Or there is another way to enable error reporting in php is .htacess file. It will enable error reporting for all files in current directory by just adding below code –

php_value display_errors 1
php_value display_startup_errors 1

Thanks for reading. Please comments if i missed anything.

Add a Comment

Your email address will not be published. Required fields are marked *

Translate »