Tutorial :WAMP: How to show warning messages in browser?



Question:

I have a WAMP installation on my machine and I am developing a PHP website in that. Can anyone tell me what settings to be changed in order to show all errors / warning messages in the browser?

Thanks in advance


Solution:1

You need to set both error_reporting and display_errors. These can be set in php.ini, in Apache (if you're using PHP as an Apache module) or during run-time, though if you set it during run-time then it won't effect some types of errors, such as parse errors.

For portability - that is, if you want to set this in the application - try setting them in an .htaccess:

# note: PHP constants such as E_ALL can't be used when setting it in Apache  php_value error_reporting 2147483647    php_flag display_errors on  

Alternatively you could set these in httpd.conf

display_errors makes sure that all reported errors are actually output to the browser (on a live server, it's typical to log them to a file instead). error_reporting specifies which types errors should be logged/displayed.

For a live server, it's generally a good idea to not to display errors publicly (but you may still want to log them). Either way, it's still a good idea to set error_reporting to a more inclusive value (2147483647 being the most inclusive value possible now and for the future according to the PHP docs) because ignoring errors is generally a bad idea.


Solution:2

First click on the wamp icon in the task panel. Then click on the 'PHP' folder followed by the 'PHP settings' folder. Make sure 'expose PHP' and 'display errors' are both checked. You can set other error settings like 'track errors' and 'display startup errors' as well.


Solution:3

Find your php.ini file, scroll down while reading the comments. There is a global setting for enabling/disabling error output. Change it accordingly. Restart your Apache.


Solution:4

I always use this code:

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

If you write code using OOP PHP, then create new methond showError() and call it in every file you need.


Solution:5

Open your php.ini and search for the option error_reporting.

Change it to E_ALL & ~E_NOTICE.

That will show all errors and warnings, but no notices.

Personally I always use E_ALL on my development machines because often the notices are signs to potential code problems.


Solution:6

If someone is using CodeIgniter then pass this code in constructor of controller. This will solve your problem.

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

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »