Rajind Pamoda
Rajind Pamoda

Reputation: 143

PHP add parameters to shutdown function

I need to send two parameters to a shutdown function on php. The shutdown function is

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;
}

As far as I know is, I can declare and register the function as below :

register_shutdown_function('shutdown');

Is there a way that I can send those two parameters to the function?

Thanks!

Upvotes: 2

Views: 768

Answers (1)

Krzysztof Raciniewski
Krzysztof Raciniewski

Reputation: 4924

Yes you should add two parameters in register_shutdown_function like this:

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

Upvotes: 4

Related Questions