This is a simple question one hour of Googling do not seem to solve. How do you catch a failed include in PHP? For the following code:
try {
include_once 'mythical_file';
} catch (Exception $e) {
exit('Fatal');
}
echo '?';
With mythical_file not existing, I get the output '?'. I know PHP can not catch failed required because it triggers a Warning Error, but here? What is the best way to catch a failed include? For example, the following works:
(include_once 'unicorn') or exit('!');
but it does not trigger an exception so I cannot retrieve file, line and stack context.