Home > PHP > Function > Filesystem > mkdir()

mkdir()

mkdir - Makes directory

Syntax

bool mkdir (string $pathname, int $mode, bool $recursive, resource $context)

Arguments

  • pathname - The directory path.
  • mode - The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the chmod() page. Note: mode is ignored on Windows. Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().
  • recursive - Allows the creation of nested directories specified in the pathname. Defaults to FALSE.
  • context - Note: Context support was added with PHP 5.0.0. For a description of contexts, refer to Stream Functions.

Description

Attempts to create the directory specified by pathname.

Version

PHP 4, 5

Return value

Returns TRUE on success or FALSE on failure.