note 86112 added to function.rmdir

From: Date: Fri, 03 Oct 2008 15:28:45 +0000
Subject: note 86112 added to function.rmdir
Groups: php.notes 
Request: Send a blank email to php-notes+get-145020@lists.php.net to get a copy of this message
here is a little improved 'removing' function with DirectoryIterator: note for PHP on windows: if using the iterator and recursively removing dirs and files, u need to unset() before leaving/continue the foreach! ( permission denied problem...) <?php function removeRessource( $_target ) { $_target = realpath($_target); //file? if( is_file($_target) ) { if( is_writable($_target) ) { if( @unlink($_target) ) { return true; } } return false; } //dir? if( is_dir($_target) ) { if( is_writeable($_target) ) { foreach( new DirectoryIterator($_target) as $_res ) { if( $_res->isDot() ) { unset($_res); continue; } if( $_res->isFile() ) { removeRessource( $_res->getPathName() ); } elseif( $_res->isDir() ) { removeRessource( $_res->getRealPath() ); } unset($_res); } if( @rmdir($_target) ) { return true; } } return false; } } ? ---- Server IP: 212.124.37.9 Probable Submitter: 80.228.208.231 ---- Manual Page -- http://www.php.net/manual/en/function.rmdir.php Edit -- https://master.php.net/note/edit/86112 Del: integrated -- https://master.php.net/note/delete/86112/integrated Del: useless -- https://master.php.net/note/delete/86112/useless Del: bad code -- https://master.php.net/note/delete/86112/bad+code Del: spam -- https://master.php.net/note/delete/86112/spam Del: non-english -- https://master.php.net/note/delete/86112/non-english Del: in docs -- https://master.php.net/note/delete/86112/in+docs Del: other reasons-- https://master.php.net/note/delete/86112 Reject -- https://master.php.net/note/reject/86112 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#145020) next »