fork(2) download
  1. <?php
  2.  
  3. function error_handler( $errno, $errmsg, $filename, $linenum, $vars ) {
  4. // error was suppressed with the @-operator
  5. if ( 0 === error_reporting() )
  6. return false;
  7.  
  8. if ( $errno !== E_ERROR )
  9. throw new \ErrorException( sprintf('%s: %s', $errno, $errmsg ), 0, $errno, $filename, $linenum );
  10.  
  11. }
  12. set_error_handler( 'error_handler' );
  13.  
  14. try {
  15. $a[1250000000]='b'; // Это поймать надо
  16. $b=1/0; // и это
  17. } catch (Exception $e) {
  18. echo 'Caught exception: ', $e->getMessage(), "\n";
  19. }
Success #stdin #stdout 0s 52488KB
stdin
Standard input is empty
stdout
Caught exception: 2: Division by zero