PHP mkdir() function

Definition and Usage

mkdir() function creates a directory.

If successful, returns true, otherwise returns false.

Syntax

mkdir(path,mode,recursive,context)
Parameters Description
path Required. Specifies the name of the directory to be created.
mode Required. Specifies the permissions. The default is 0777.
recursive Required. Specifies whether to set the recursive mode.
context Required. Specifies the environment of the file handle. Context is a set of options that modify the behavior of a modifiable stream.

Description

mkdir() tries to create a directory named by path the specified directory.

Default mode is 0777, meaning the maximum possible access rights.

Tips and Comments

Note:mode is ignored under Windows. Since PHP 4.2.0, it has become an option.

Note:for context Support is added in PHP 5.0.0.

Note:recursive The parameter is added in PHP 5.0.0.

Example

<?php
mkdir("testing");
?>