Skip to content

Instantly share code, notes, and snippets.

@seanvree
Created January 31, 2018 16:22
Show Gist options
  • Save seanvree/a337158bd9cc32a0dbc9d5943628528a to your computer and use it in GitHub Desktop.
Save seanvree/a337158bd9cc32a0dbc9d5943628528a to your computer and use it in GitHub Desktop.
logarr_delete
<?php
$file = 'example.txt';
echo "$file\n";
echo "<br>";
$fh = fopen($file, 'a');
fwrite($fh, '<h1>File deleted and backed up</h1>');
fclose($fh);
if($fh == true)
echo "Write: success: $file\n";
else
echo "Write: fail: $file\n";
echo "<br>";
$newfile = 'example.txt.bak';
if (!copy($file, $newfile))
echo "Copy: fail: $newfile";
else
echo "Copy: success: $newfile";
echo "<br>";
$delete = unlink($file);
if($delete == true)
echo "Delete: success: $file\n";
else
echo "Delete: fail: $file\n;";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment