note 18210 added to function.rmdir

From: Date: Mon, 14 Jan 2002 21:10:57 +0000
Subject: note 18210 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-24811@lists.php.net to get a copy of this message
A small addition to the function above (which helped me a lot when I couldn't get system() or exec() to work on my Win32 system): I suggest you check for the file or directory you're trying to delete, to avoid error messages: function delete($file) { if (file_exists($file)) { chmod($file,0777); if (is_dir($file)) { $handle = opendir($file); while($filename = readdir($handle)) { if ($filename != "." && $filename != "..") { delete($file."/".$filename); } } closedir($handle); rmdir($file); } else { unlink($file); } } } delete ($mydir); Pål Degerstrøm -- http://www.php.net/manual/en/function.rmdir.php http://master.php.net/manage/user-notes.php?action=edit+18210 http://master.php.net/manage/user-notes.php?action=delete+18210 http://master.php.net/manage/user-notes.php?action=reject+18210

« previous php.notes (#24811) next »