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/
2- Open the file in editor and find “Error handling and logging”
3- To enable errors to display errors in browser remove (;) from
; display_errors = On; display_startup_errors = 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.
Related Posts
- HTML Doctypes – A Complete Guide No Comments | Jul 25, 2015
- How to alphabetical sort mysql query field variable in PHP? 2 Comments | Mar 11, 2015
- MongoDB Cloud – How to Create a Project and access via Compass? No Comments | Feb 17, 2019
- Mysql subquery with IN and NOT IN operators No Comments | May 26, 2015
About The Author
GK
GK is the man behind Ecompark. I love to write on new technology, latest gadgets, deals, programming updates and gaming entertainment.