How to catch error from include "file.php"?
Posted: Mon Sep 22, 2008 11:44 am
I have a simple template system that uses extract, ob_start, include, and ob_get_contents. I've ran into several instances where errors in the template has resulted in a blank page being display. This is, of course, unless I remove the error suppressor "@" from the include line, which gives me the parse error message. What I would prefer is to hide the specific error, but catch it and throw my own custom error message. Unfortunately I haven't figured out just how to do that. I've tried...
...and...
Is there a way to still use @include and somehow catch the error? I think error_get_last() is the answer, but I first need to figure out how to get @include to trigger false.
Code: Select all
if(!@include("file.php")) {...}Code: Select all
if((@include "file.php") === false) {...}