Jump to content

Help with mkdir


Perad

Recommended Posts

Could someone help me get my head around the mkdir() function.

 

I have the following.

 

$root = getcwd().'/cities/'

 

This is where I want to make the folder.

 

I want to make a folder containing the variable $name.

 

So the folder path will be

 

$root = getcwd().'/cities/'.$name;

 

How do I set this with getcwd. Do I just specify the complete path and it will automatically generate the new folder.. i.e.

 

mkdir($root, 0777);

 

Or is there something more to it?

 

 

 

My second question. How can I change folder name with out edited the contents of the folder. Is there another function for this?

Link to comment
Share on other sites

How do I set this with getcwd. Do I just specify the complete path and it will automatically generate the new folder.. i.e.

 

mkdir($root, 0777);

 

Or is there something more to it?

 

Why not try it? If you need to create a dir more than one dir deep (ie you have an empty /foo and want to create /foo/bar/bob) you'll need to look at the third argument, recursive.

 

My second question. How can I change folder name with out edited the contents of the folder. Is there another function for this?

 

Yes, rename().

Link to comment
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.