E_ERROR timeout exception перехват в php
15/02/11 в 21:02 | просто прочесть =)Отличный пример нашел у http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a.
Спешу поделится.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | set_time_limit(3); set_error_handler('myErrorHandler'); register_shutdown_function('fatalErrorShutdownHandler'); function myErrorHandler($code, $message, $file, $line) { echo "ok"; lambda(); } function fatalErrorShutdownHandler() { $last_error = error_get_last(); if ($last_error['type'] === E_ERROR) { // fatal error myErrorHandler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']); } } function lambda() { error_reporting(0); for($x=0;$x<=10000000;$x++) { md5($x); } error_reporting(-1); } lambda(); |