Example :
Say I have a logging class, and I use a global variable instance of it throughout the code.
$logger = new Logger();
function correctWorking()
{
global $logger;
$logger->log("this is correct");
}
function failing()
{
$logger->log("this is fatal error"); /* here fatal error comes, : Call to a member
function log() on a non-object in ...
*/
moreImportantWork();
}
Please do not suggest better coding practices,I am working on them.
My main curiousity is, how can I bypass the fatal error line, if the error occurs,
as logging is not as important as keeping the app running.
You cannot.
You can suppress the error output like
@$logger->log("this is fatal error");but:Instead, fix the fatal error.