title: Is it possible to catch all PHP errors occured in a file
body: <p>I want to catch all PHP errors (E_ERROR, E_WARNING, E_NOTICE,..) in a page and log it to MongoDB in order to read and comment better on it.</p>
  
  <p>I found a way to catch last occured error with 'error_get_last' and send it to anywhere i want with 'register_shutdown_function' <a href="https://stackoverflow.com/questions/4410632/handle-fatal-errors-in-php-using-register-shutdown-function">Handle fatal errors in PHP using register_shutdown_function()</a></p>
  
  <p>But what if my file have more than one errors, like warnings and notices, how can i get all errors in a file? Is this possible? What i need is something like 'error_get_all'.</p>
  
  <p>Here you can find my code, this code has one fatal error, two warning and one notice:</p>
  
  <pre><code>function shutdown() {
    $error = error_get_last();
    if ($error['type'] === E_ERROR || $error['type'] === E_WARNING || $error['type'] === E_NOTICE) {
      var_dump($error);
    }
  }
  
  register_shutdown_function('shutdown');
  
  spl_autoload_register('foo');
  
  $x = 5;
  $y = 0;
  
  echo 'x/y: ' . $x / $y . '&lt;br/&gt;';
  
  foreach ($noarray as $noelement) {
    echo 'no element: ' . $noelement . '&lt;br/&gt;';
  }
  </code></pre>