note 104370 added to function.unlink
| From: | holdoffhunger at gmail dot com | Date: | Sat, 11 Jun 2011 15:28:29 +0000 |
| Subject: | note 104370 added to function.unlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180439@lists.php.net to get a copy of this message | ||
There seems to be a lot of independent investigators here looking for buggy execution of this code
(which actually be caused by or worsened by a Windows, Server operating system). The main issue
seems to be knowing for certain that the file was actually deleted, for example, not producing an
error when a file isn't deleted on the command, or producing an error when the file actually is
deleted. Anyhow, the following is a tiny piece of code that absolutely deletes, even if it produces
an error message, or never finishes, if it is unable to delete.
There are two outcomes: (1) It deletes the file, and continues happily along, error message, or not.
(2) It can't delete the file, can't modify the permissions, etc., and therefore, the
script never completes, or it may throw some PHP errors at you eventually.
<?php
while(is_file($data_file_to_delete) == TRUE)
{
chmod($data_file_to_delete, 0666);
unlink($data_file_to_delete);
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 68.0.209.235
----
Manual Page -- http://www.php.net/manual/en/function.unlink.php
Edit -- https://master.php.net/note/edit/104370
Del: integrated -- https://master.php.net/note/delete/104370/integrated
Del: useless -- https://master.php.net/note/delete/104370/useless
Del: bad code -- https://master.php.net/note/delete/104370/bad+code
Del: spam -- https://master.php.net/note/delete/104370/spam
Del: non-english -- https://master.php.net/note/delete/104370/non-english
Del: in docs -- https://master.php.net/note/delete/104370/in+docs
Del: other reasons-- https://master.php.net/note/delete/104370
Reject -- https://master.php.net/note/reject/104370
Search -- https://master.php.net/manage/user-notes.php