Using error_log with print_r to debug PHP (writing objects to log file)

This link has some good information on how to debug PHP scripts by writing objects to the PHP log file using print_r with error_log. This is helpful — necessary, even — when you’re writing PHP code that doesn’t write directly to the browser.

The basic idea involves writing PHP code that looks like this:

error_log(print_r($myObject, true))

Don’t leave the true part out; if you do, the output will either go to your web browser or get lost somewhere else.