note 79165 added to language.exceptions
| From: | Jason at osu1 dot php dot net | Date: | Wed, 14 Nov 2007 06:36:45 +0000 |
| Subject: | note 79165 added to language.exceptions | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-132250@lists.php.net to get a copy of this message | ||
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!
----
Server IP: 69.147.83.197
Probable Submitter: 70.59.171.57
----
Manual Page -- http://www.php.net/manual/en/language.exceptions.php
Edit -- https://master.php.net/note/edit/79165
Del: integrated -- https://master.php.net/note/delete/79165/integrated
Del: useless -- https://master.php.net/note/delete/79165/useless
Del: bad code -- https://master.php.net/note/delete/79165/bad+code
Del: spam -- https://master.php.net/note/delete/79165/spam
Del: non-english -- https://master.php.net/note/delete/79165/non-english
Del: in docs -- https://master.php.net/note/delete/79165/in+docs
Del: other reasons-- https://master.php.net/note/delete/79165
Reject -- https://master.php.net/note/reject/79165
Search -- https://master.php.net/manage/user-notes.php