How can I debug PHP without changing php.ini?
By default, displaying PHP errors is turned off in php.ini. This is a sensible setting, because debug information often reveals information that is not meant for the outside world. However, if you are getting errors, it is useful to turn it on temporarily. You can do this with runtime settings. By putting the code below in the program (or the main program index.php), you can catch the errors:
ini_set('display_errors', 1);
ini_set('log_errors', 1);
ini_set('error_log', dirname(__FILE__) . '/error_log.txt');
error_reporting(E_ALL);
Note that errors are not shown if error reporting is turned on in the same script that contains the error. It is better to create a new script, turn on error reporting in it and then include the old script. Alternatively, you can turn on error reporting in the .htaccess file.
