Thursday, June 09, 2005

Everything You Wanted To Ask About PHP Error Handling (But Were Afraid To Ask)

This has a lot of super info on logging errors and error handling:

education.nyphp.org/.../PH_error_handle.php

In short, there are two days to pipe errors to a log rather than the screen output. One way (described in the article) is by modifying the php.ini file. Another way is inline on the scripts as you write them. I put in code to that effect below (it's going into my directory while I try this out)


error_reporting(E_ALL);

ini_set('log_errors','1');
ini_set('display_errors','0');
ini_set('error_log', '/home/yourpath/tothe/errorlogs/phperrors.log');


One thing I found: error reporting will only append a file and not make s new error log file. So, I added a blank log as a starting point and gave it generous write permissions.

No comments: