I can try to turn on error logging. What if I just don't know how to turn on error logging on my server? Read on to see a couple of simple ways to debug without logging or displaying errors.
Solution
First you should have some idea what the offending line is. In my case, my Javascript was using a function which expects a JSON result from my server, but my server sends a non-JSON-formatted result due to some error.
If the offending line is a function call such as SEmailUtil::emailMeFailure, then adding @ in front of it would suppress any error raised when the function is executed:
@SEmailUtil::emailMeFailure(...);
A usual cause of an error is denied file access due to lack of permission. Consider the following line of code in PHP:
$fh = fopen("/home/ubuntu/log/op/email-sent.log", 'a+') or die("can't open email-sent.log");
This line of code could be the problem. Your web server needs write access to /home/ubuntu/log/op/email-sent.log.
So simply scan the suspicious offending functions and see if they contain lines of code that need file permission for your web server's user. Suppose your web server's user is www-data, then the following command grants the web server access to the file 'email-sent.log':
sudo chown www-data:www-data email-sent.log
Questions? Let me know!