[SOLVED] minor question about closedir()

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
bckennyw
Forum Newbie
Posts: 11
Joined: Wed Nov 26, 2003 10:25 am

[SOLVED] minor question about closedir()

Post by bckennyw »

I really wonder what it is for. 'cuz like... say I do...

Code: Select all

$dir = opendir("path/");
and if I wanna delete it, I don't have to call the closedir($dir) before doing the rmdir($dir).

What is that for anyways?
Last edited by bckennyw on Sat Nov 29, 2003 4:16 pm, edited 1 time in total.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

I could be wrong but, as far as I understand it, you should get an error if you don't close the stream before rmdir().

What error reproting level do you have? Should always develop with E_ALL.
bckennyw
Forum Newbie
Posts: 11
Joined: Wed Nov 26, 2003 10:25 am

Post by bckennyw »

Hm... I am not sure 'cuz I posted the script (PHP) with a hosting company. How could I find out?

And yes... I'm pretty sure that if I do closedir($dir) before deleting it, then I'll have error; no error otherwise... it's SO weird and doesn't make any sense.
McGruff
DevNet Master
Posts: 2893
Joined: Thu Jan 30, 2003 8:26 pm
Location: Glasgow, Scotland

Post by McGruff »

Check out [php_man]ini_get()[/php_man] to examine the host php.ini file.

opendir opens a stream - hence the error when you try to delete a directory for which a stream is currently open.
Post Reply