array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'it', ), 'this' => array ( 0 => 'function.get-error-handler.php', 1 => 'get_error_handler', 2 => 'Gets the user-defined error handler function', ), 'up' => array ( 0 => 'ref.errorfunc.php', 1 => 'Error Handling Funzioni', ), 'prev' => array ( 0 => 'function.error-reporting.php', 1 => 'error_reporting', ), 'next' => array ( 0 => 'function.get-exception-handler.php', 1 => 'get_exception_handler', ), 'alternatives' => array ( ), 'source' => array ( 'lang' => 'en', 'path' => 'reference/errorfunc/functions/get-error-handler.xml', ), 'history' => array ( ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); contributors($setup); ?>

get_error_handler

(PHP 8 >= 8.5.0)

get_error_handlerGets the user-defined error handler function

Descrizione

get_error_handler(): ?callable

Returns the current error handler function, if any.

Elenco dei parametri

Questa funzione non contiene parametri.

Valori restituiti

Returns the currently defined error handler (if any). If the built-in error handler is used null is returned.

The returned handler is the exact callable value that was passed to set_error_handler() to define it.

Esempi

Example #1 get_error_handler() example

<?php

$handler
= function (int $errno, string $errstr, ?string $errfile, ?int $errline) {
echo
"Error: " . $errstr . "\n";
};

var_dump(get_error_handler()); // NULL

set_error_handler($handler);

var_dump(get_error_handler() === $handler); // bool(true)

?>

Note

Suggerimento

Prior to PHP 8.5.0, this functionality can be provided by the following polyfill:

<?php
if (!function_exists('get_error_handler')) {
function
noop_error_handler() {
}
function
get_error_handler(): ?callable {
$handler = set_error_handler('noop_error_handler');
restore_error_handler();
return
$handler;
}
}
?>

Vedere anche: