More 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! :)
You might also enjoy:
-
Often is the case where you are working on a specific PHP script but don't dare turn on error reporting in PHP since the server you are working on is a prod ...
-
The easiest way to set up a custom PHP 404 error page under Apache is to make use of the .htaccess file, a system file that allows you to override some of t ...
-
Annoyingly, I got saddled with a database for a system which contained a whole lot of "uncleaned data", in other words data with a lot of trailing and leadi ...
-
A nice trick to keep in mind when you are busy creating a bash script in Linux is to allow for tracing, particularly when your script seems to be falling ov ...
-
A bash script is simply put a file containing a list of commands to be executed by the bash shell (remember, there are a number of different shells availabl ...