note 59036 added to function.rmdir
| From: | stefano at takys dot it | Date: | Thu, 24 Nov 2005 14:26:48 +0000 |
| Subject: | note 59036 added to function.rmdir | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-99025@lists.php.net to get a copy of this message | ||
becouse all the examples fails if there are hiddenfiles (.filename) somewhere, I write this short
and power function to erase a tree independtly from his content
/**
* rm() -- Very Vigorously erase files and directories. Also hidden files !!!!
*
* @param $dir string
* be carefull to:
* if($obj=='.' || $obj=='..') continue;
* if not it will erase all the server...it happened to me ;)
* the function is permission dependent.
*/
function rm($dir) {
if(!$dh = @opendir($dir)) return;
while (($obj = readdir($dh))) {
if($obj=='.' || $obj=='..') continue;
if (!@unlink($dir.'/'.$obj)) rm($dir.'/'.$obj);
}
@rmdir($dir);
}
----
Manual Page -- http://www.php.net/manual/en/function.rmdir.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+59036
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=non-english
Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes&reason=already+in+docs
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+59036&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+59036&report=yes
Search -- http://master.php.net/manage/user-notes.php