note 104372 deleted from function.unlink by danbrown
| From: | danbrown@php.net | Date: | Sat, 11 Jun 2011 16:12:21 +0000 |
| Subject: | note 104372 deleted from function.unlink by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-180444@lists.php.net to get a copy of this message | ||
Note Submitter: holdoffhunger at gmail dot com
----
I have added an improvement to the previous while method I posted for absolutely deleting a file.
The while was changed to a for that includes one additional line reporting error information, should
an error occur.
<?php
for($i = 1; is_file($data_file_to_delete) == TRUE; $i++)
{
chmod($data_file_to_delete, 0666);
unlink($data_file_to_delete);
if($i > 1){ print("<b><u>Error!</u></b> - Deleting
$data_file_to_delete Failed on Try #$i. <br><br>\n\n"); }
}
?>
Both versions can be useful.