note 119949 added to function.rmdir

From: Date: Sun, 25 Sep 2016 22:44:59 +0000
Subject: note 119949 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-206673@lists.php.net to get a copy of this message
itay at itgoldman's function falls into an infinite loop if the $src directory doesn't exist. Here's a fix - one should do at least a file_exists() check before the loop: function rrmdir($src) { if (file_exists($src)) { $dir = opendir($src); while (false !== ($file = readdir($dir))) { if (($file != '.') && ($file != '..')) { $full = $src . '/' . $file; if (is_dir($full)) { rrmdir($full); } else { unlink($full); } } } closedir($dir); rmdir($src); } } Thanks to itay for the original function, though, it was helpful. ---- Server IP: 72.52.91.14 Probable Submitter: 89.176.135.68 ---- Manual Page -- http://php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/119949 Del: integrated -- https://master.php.net/note/delete/119949/integrated Del: useless -- https://master.php.net/note/delete/119949/useless Del: bad code -- https://master.php.net/note/delete/119949/bad+code Del: spam -- https://master.php.net/note/delete/119949/spam Del: non-english -- https://master.php.net/note/delete/119949/non-english Del: in docs -- https://master.php.net/note/delete/119949/in+docs Del: other reasons-- https://master.php.net/note/delete/119949 Reject -- https://master.php.net/note/reject/119949 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#206673) next »