How does php get the error parameters of set_error_handler faces for external use?

function myErrorHandler($errno, $errstr, $errfile, $errline)
{
  
  switch ($errno) {
  case E_USER_WARNING:
  $errno = "USER_WARNING";
  break;
  case E_USER_NOTICE:
  $errno = "USER_NOTICE";
  break;
  case E_NOTICE:
  $errno = "NOTICE";
  break;
  case E_WARNING:
  $errno = "WARNING";
  break;
  case E_RECOVERABLE_ERROR:
  $errno = "RECOVERABLE_ERROR";
  break;
  case E_ALL:
  $errno = "ALL";
  break;
  default:
  $errno = "Unknown Error Type";
  break;
  }

  return true;
}

set_error_handler("myErrorHandler");

how can I take out the errno errstr errfile errline and use it outside the function?


can be combined with try.catch. To use

 $trace = (new \Exception())->getTrace()[0];
echo '<br>:'.$trace['file'].':'.$trace['line'];
Menu