get_error_handler()

get_error_handler() — Gets the user-defined error handler function.

Built-in function of PHP 8.5. The manual lists it as available in PHP 8 >= 8.5.0. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.

Signature

get_error_handler(): ?callable

Parameters

This function takes no parameters.

Return value

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.

Example

A runnable snippet:

$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)

See also

error_reporting(), set_error_handler(), restore_error_handler(), trigger_error()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page get_error_handler() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.