HomeMenu
Jesus · Bible · HTML · CSS · JS · PHP · SVG · Applications

register_shutdown_function

Description

The register_shutdown_function of Function Handling for PHP registers a function for execution on shutdown.

Syntax

register_shutdown_function(
    callable $callback,
    mixed ...$args
): void

Parameters

callback

The shutdown callback to register.

The shutdown callbacks are executed as the part of the request, so it's possible to send output from them and access output buffers.

args

It is possible to pass parameters to the shutdown function by passing additional parameters.

Return

No value is returned.

Examples

1 · callback

<?

function myfunction()
{
    echo __FUNCTION__;
}

$callback = "myfunction";

register_shutdown_function($callback);
myfunction

2 · args

<?

function myfunction($myparameter)
{
    echo __FUNCTION__ . PHP_EOL;
    print_r($myparameter);
}

$callback = "myfunction";
$args =
[
    "myparameter1",
    "myparameter2",
    "myparameter3"
];

register_shutdown_function($callback, $args);
myfunction
Array
(
    [0] => myparameter1
    [1] => myparameter2
    [2] => myparameter3
)