note 97302 deleted from function.rmdir by danbrown
| From: | danbrown@php.net | Date: | Tue, 13 Apr 2010 14:06:35 +0000 |
| Subject: | note 97302 deleted from function.rmdir by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-168200@lists.php.net to get a copy of this message | ||
Note Submitter: phexon at gmail dot com
----
The function (deltree) from Kevin and Anonymous is not safe enough. And it cannot delete the hidden
items.
If you have two directories "/home/myname/abc", "/home/myname/abcde". And you
want to delete the directory "/home/myname/abc" only, it will delete
"/home/myname/abcde" also.
But if you add a slash '/' to the $dir, it will be safe.
<?php
$dir = $dir."/";
deltree($dir);
?>