PHPMore often than not when you are working in a hosted environment that you yourself don’t run, the webserver that you are uploading your scripts to will have the php.ini file set so that all errors are captured in log files instead of going to the screen. Obviously this is far more secure than printing out everything to the screen, but there are certainly times when this can become quite a headache and you actually wish to just see what the heck it is that keeps bombing your script at runtime.

The solution to this problem is to overwrite the php.ini directives by placing the following block of code at the top of your script:

// Report all PHP errors
ini_set(‘display_errors’, 1);
error_reporting(E_ALL);

If per chance you rather want to send all the errors to a file whose path you do know, you can also set something like:

ini_set(‘log_errors’, 1);
ini_set(‘error_log’, dirname(__FILE__) . ‘/error_log.txt’);

This allows you to overcome the security-imposed limitation on a script by script basis, something which has proven to be quite useful over the years! :)