note 81160 added to function.rmdir

From: Date: Sat, 16 Feb 2008 06:13:43 +0000
Subject: note 81160 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-136196@lists.php.net to get a copy of this message
I've improved the function of vboedefeld at googlemail dot com: The function worked fine but I had a typo in the variable name I passed to the function, and as a result I have lost all files (I've had a backup) So I made the function check first if the passed path is a directory: <?php function deltree($f) { if (is_dir($f)) { foreach(glob($f.'/*') as $sf) { if (is_dir($sf) && !is_link($sf)) { deltree($sf); rmdir($sf); } else { unlink($sf); } } } else { die("Error: not a directory - $f"); } } ?> ---- Server IP: 61.195.146.164 Probable Submitter: 219.98.211.170 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/81160 Del: integrated -- https://master.php.net/note/delete/81160/integrated Del: useless -- https://master.php.net/note/delete/81160/useless Del: bad code -- https://master.php.net/note/delete/81160/bad+code Del: spam -- https://master.php.net/note/delete/81160/spam Del: non-english -- https://master.php.net/note/delete/81160/non-english Del: in docs -- https://master.php.net/note/delete/81160/in+docs Del: other reasons-- https://master.php.net/note/delete/81160 Reject -- https://master.php.net/note/reject/81160 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#136196) next »