Is there any method or function in php to delay a function execution after a period of time
<?php
function create_file()
{
$myfile = fopen("newfile1.txt", "w") or die("Unable to open file!");
$txt = "John Doe\n";
fwrite($myfile, $txt);
$txt = "hello\n";
fwrite($myfile, $txt);
fclose($myfile);
}
function delete_file()
{
unlink("newfile1.txt"); //delete after 24 H
}
?>
I create many files and some time the execution of the code breaks and the file it can be deleted after using the file.
So I want to execute the delete function after 24 h of the file creation. it ts possible to do that with php
any help will be appreciated