While studying for the Zend PHP Exam I came across the following contradicting information:
From the Zend PHP 5.3 Study guide v1a - PDF available here.
The answer:
And information from the php Architect's Zend PHP 5 Certification Study Guide by Davey Shafik ISBN: 0-9738621-4-9 Page 128
Can someone tell me which one is true?
Thanks
The primary method of handling exceptions in PHP is the try-catch. In a nutshell, the try-catch is a code block that can be used to deal with thrown exceptions without interrupting program execution. In other words, you can "try" to execute a block of code, and "catch" any PHP exceptions that are thrown.
Fatal Error Fatal errors are ones that crash your program and are classified as critical errors. An undefined function or class in the script is the main reason for this type of error.
If an exception is not caught, it is intercepted by a function called the uncaught exception handler. The uncaught exception handler always causes the program to exit but may perform some task before this happens. The default uncaught exception handler logs a message to the console before it exits the program.
Fatal errors or recoverable fatal errors now throw instances of Error in PHP 7 or higher versions. Like any other exceptions, Error objects can be caught using a try/catch block.
From the php manual, please note the unless
.
If an exception is not caught, a PHP Fatal Error will be issued with an "Uncaught Exception ..." message, unless a handler has been defined with set_exception_handler().
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With