Jump to content

Recommended Posts

I have a question about the php mkdir() function.  The docs say it returns TRUE on SUCCESS and FALSE on FAILURE.

 

However, if you call this function on a directory that already exists, does it a) return true or false, and more importantly b) does it erase the current directory contents or leave it untouched?  I understand that is_dir would likely be called, too, but I need to know if files would be erased in case some call ever got through the cracks. 

Link to comment
https://forums.phpfreaks.com/topic/63616-solved-mkdir-question/
Share on other sites

I just did a test an it is turning '0' when a directory exists and also a warning 'Warning: mkdir() [function.mkdir]: File exists in blah blah'. Anyways just to be sure and surpress error messages u can use file_exists() to check if the directory exists or not, but in each case it will not delete a directory and all its files and create a blank one.

Link to comment
https://forums.phpfreaks.com/topic/63616-solved-mkdir-question/#findComment-317064
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.