Thanks Jason,

That makes much more sense now. I forgot about recursive functions, as I
don't use them often. I should look into it further. It seems to be very
helpful in some cases. Thanks again for your help.

- Nilaab

> -----Original Message-----
> From: Jason Wong [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, December 19, 2002 3:53 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP] delete() and unlink()
>
>
> On Thursday 19 December 2002 17:39, [EMAIL PROTECTED] wrote:
> > Hello Everyone,
> >
> > I'm using a test server on Windows XP. I have the following
> function (which
> > I got from the comment notes on php.net) that works wonders
> when deleting
> > directories that are not empty on a Windows system.
>
> Good.
>
> > But, I'm a bit
> > confused. I searched for the delete() function on php.net and
> it said that
> > delete() was not a real function, but a dummy manual entry for those who
> > are actually looking for the unlink() function.
>
> delete() is a dummy entry in the manual so people looking for
> said function
> will be directed to unlink() which is the correct function to use.
>
> > So then why does the
> > delete() function work in my script?
>
> delete() is undefined in php, that is why you can define your own
> function
> called delete().
>
> > I tried using the unlink() function in
> > place of the delete() function, but unlink() gave me many
> errors (possibly
> > because of permissions).
>
> unlink() can only remove/delete directories that are empty.
>
> > Is there an error in the manual or is it just me?
>
> There's no error in the manual (with regards to this subject). Probably a
> misunderstanding on your part.
>
> > Is there a difference in the two functions? Does the delete()
> function not
> > care about permissions as opposed to the unlink() function?
> This is really
> > bugging me. Can someone clear the air?
>
> The delete() function as defined below is recursive and will
> automatically go
> inside non-empty directories and empty them first.
>
> > $c_dir = "$DOCUMENT_ROOT/world/admin/backup2";  // current directory
> >
> > function delete($dir) {
> >  if (file_exists($dir)) {
> >     umask(0);
> >     chmod($dir,0777);
> >    if (is_dir($dir)) {
> >      $handle = opendir($dir);
> >      while($dirname = readdir($handle)) {
> >        if ($dirname != "." && $dirname != "..") {
> >         delete($dir."/".$dirname);
> >        }
> >      }
> >     closedir($handle);
> >      rmdir($dir);
> >    } else {
> >     unlink($dir);
> >    }
> >  }
> > }
> >
> > delete ($c_dir);
>
> To summarise -- there is no delete() function in php, the
> delete() function
> you're using is a user-defined function and as such will do
> whatever you can
> make it do.
>
> --
> Jason Wong -> Gremlins Associates -> www.gremlins.biz
> Open Source Software Systems Integrators
> * Web Design & Hosting * Internet & Intranet Applications Development *
>
> /*
> Garbage In -- Gospel Out.
> */
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to