get_exception_handler()

get_exception_handler() — Gets the user-defined exception 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_exception_handler(): ?callable

Parameters

This function takes no parameters.

Return value

Returns the currently defined exception handler. If no handler is defined, null is returned. The returned handler is the exact callable value that was passed to set_exception_handler() to define it.

Example

A runnable snippet:

$handler = function (Throwable $ex) { echo "Exception: " . $ex::class . ": " . $ex->getMessage() . "\n"; }; var_dump(get_exception_handler()); // NULL set_exception_handler($handler); var_dump(get_exception_handler() === $handler); // bool(true)

See also

set_exception_handler(), restore_exception_handler(), restore_error_handler(), error_reporting()

All PHP 8.5 built-in functions

Reference card built from the PHP manual page get_exception_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.