Download - Webinar PHParty7 - Errors handlings
![Page 1: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/1.jpg)
Errors handlingWebinar PHParty7 France - 28/11/15
![Page 2: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/2.jpg)
Errors VS Exceptions
![Page 3: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/3.jpg)
Errors VS Exceptions
E_ERROR, E_WARNING, E_PARSE, E_NOTICE, ...
Errors
![Page 4: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/4.jpg)
Errors VS Exceptions
Exception, RuntimeException, ErrorException, ...
Exceptions
![Page 5: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/5.jpg)
Actual Exception hierarchy
![Page 6: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/6.jpg)
Actual Exception hierarchy
![Page 7: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/7.jpg)
Error & Exception handling
Error handling
Exception handling
set_error_handler(function ($errno, $errstr, $errfile, $errline) { echo "Error $errstr at line $errline";});
try { mayThrowException();} catch (Exception $e) { echo 'Exception: '.$e->getMessage();}
![Page 8: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/8.jpg)
Fatal Errors
● Fatal errors cannot be gracefully handled● Error handler is not called● Finally block will not be invoked● Destructors are not called
![Page 9: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/9.jpg)
PHP7 Exceptions
![Page 10: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/10.jpg)
PHP7 Exceptions
![Page 11: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/11.jpg)
Error & Exception handlingErrors and fatal errors handling
try { inexistant_function();} catch (Error $e) { echo 'Error: '.$e->getMessage();}
// PHP5:// Fatal error: Call to undefined function// inexistant_function() in …// PHP7:// Error: Call to undefined function inexistant_function()
![Page 12: Webinar PHParty7 - Errors handlings](https://reader035.vdocuments.site/reader035/viewer/2022070509/58a5d1fa1a28ab6c2a8b656d/html5/thumbnails/12.jpg)
Bibliography
RFC for EngineException: https://wiki.php.net/rfc/engine_exceptions_for_php7
Reviewed RFC about Throwable: https://wiki.php.net/rfc/throwable-interface
Article about PHP7 Throwable and Errors: https://trowski.com/2015/06/24/throwable-exceptions-and-errors-in-php7/
Stackoverflow, Errors VS Exception:http://stackoverflow.com/questions/…