PHP Exceptions
PHP 5 introduces exceptions using a Java-like syntax. All exceptions extend the standard Exception class, meaning that you can create your own custom exceptions.
<?php
try { /* begin exception block */
$fp = fopen(__FILE__, "r");
if (!$fp) {
/* throw exception, error occurred */
throw new Exception('no such file', 9);
}
} catch (Exception $e) { /* what to do on error (thrown exception) */
echo $e->getCode(); // error code
echo $e->getFile(); // file where exception was thrown
echo $e->getLine(); // line on which exception was thrown
echo $e->getMessage(); // error message
print_r($e->getTrace()); // print backtrace
}
?>
Related Results :
Note :
- Related Posts are generally User Blog posts.
- or Other tutorials from other networks of w3clan.com.
- Any registered user can create related posts based on search term tags.
About the Author
Search Lesson
Search Terms :
#php exceptions
#php getcode()
#php getfile()
#php getline()
#php getmessage()
#php gettrace()
Bookmark Course
Loading ...