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'];
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34eed-2bf47.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34eed-2bf47.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?