What is the difference between using a class method and a standalone function as a shutdown handler in PHP?

Using a class method as a shutdown handler in PHP requires creating an instance of the class and passing it as an array to the `register_shutdown_function()` function. On the other hand, using a standalone function as a shutdown handler simply involves passing the function name directly to `register_shutdown_function()`. Both methods are valid, but using a class method allows for better encapsulation and organization of related functionality.

// Using a class method as a shutdown handler
class ShutdownHandler {
    public function handleShutdown() {
        // Shutdown handling logic here
    }
}

$handler = new ShutdownHandler();
register_shutdown_function([$handler, 'handleShutdown']);