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
- CSS & CSS3 Media Query – An Introduction No Comments | Jan 8, 2015
- What is Shell in Unix/Linux? No Comments | Oct 14, 2014
- What are the differences between == and === in JavaScript? No Comments | Mar 2, 2016
- MongoDB Cloud – How to Create a Project and access via Compass? No Comments | Feb 17, 2019
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.