note 79165 deleted from language.exceptions by bjori
| From: | bjori@php.net | Date: | Fri, 28 Nov 2008 17:30:09 +0000 |
| Subject: | note 79165 deleted from language.exceptions by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-147088@lists.php.net to get a copy of this message | ||
Note Submitter: Jason
----
If you are wondering how to catch an include error and throw an exception, you can do so by doing:
<?php
try {
if(!@include('/path/to/file.php')) {
throw new Exception('Failed to load blabla');
}
}
catch(Exception $e) {
print $e->getMessage();
}
?>
This is helpful for people with custom Exception handlers that need to escape the default warning.
Too bad you can't, without using this method, catch the exception..
If you insist on using require() instead, you must understand that include() and require() are
identical in all ways, except that the way they handle errors - require throws E_FATAL when the file
isn't found, include issues E_WARNING, that's the only difference!