theuser26 Posted April 24, 2011 Share Posted April 24, 2011 Hello guys. Is it possible to catch a fatal error and then do something? What I need to do is to catch the error and run the script a second time, before the first execution ends. Kind regards and thanks for advance. Quote Link to comment https://forums.phpfreaks.com/topic/234555-catch-fatal-error/ Share on other sites More sharing options...
requinix Posted April 24, 2011 Share Posted April 24, 2011 No, it is not possible. Fatal errors are exactly that: fatal. (There are, however, catchable fatal errors. Those are different. But you'll know if you encounter them.) Quote Link to comment https://forums.phpfreaks.com/topic/234555-catch-fatal-error/#findComment-1205438 Share on other sites More sharing options...
dreamwest Posted April 24, 2011 Share Posted April 24, 2011 Use triggers and E_RECOVERABLE_ERROR or E_ERROR http://www.wizecho.com/nav=php&s=errors Quote Link to comment https://forums.phpfreaks.com/topic/234555-catch-fatal-error/#findComment-1205444 Share on other sites More sharing options...
requinix Posted April 24, 2011 Share Posted April 24, 2011 Contrary to popular belief, E_ERRORs cannot be caught. Period. Example: function errorhandler($errlvl, $errmsg) { $levels = array(E_ERROR => "E_ERROR", E_WARNING => "E_WARNING", E_NOTICE => "E_NOTICE"); echo "Caught a $levels[$errlvl]: $errmsg\n"; } set_error_handler("errorhandler"); nosuchfunction(); Fatal error: Call to undefined function nosuchfunction() in X on line Y Quote Link to comment https://forums.phpfreaks.com/topic/234555-catch-fatal-error/#findComment-1205468 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.