PHP 为关闭函数添加参数

PHP add parameters to shutdown function

我需要向 php 上的关闭函数发送两个参数。关机功能是

function shutdown($newfile,$back_file)
{
        if(file_exists("../Content/8/$newfile")){
            unlink("../Content/8/$newfile");
        }
        if(file_exists("../Content/8/$back_file")){
            unlink("../Content/8/$back_file");
        }
    echo "Script executed with success $back_file", PHP_EOL;
}

据我所知,我可以如下声明和注册函数:

register_shutdown_function('shutdown');

有没有办法可以将这两个参数发送给函数?

谢谢!

是的,您应该像这样在 register_shutdown_function 中添加两个参数:

register_shutdown_function('shutdown', $newFile, $previousFile);