PHP mkdir() function

This function is used to create a directory at the specified path or location.

Syntax

mkdir(pathname, mode, recursion);

The pathname is the location where directory is created. The mode is the access permission, by default it is 0777. recursion is used to create a nested path. It is a boolean value, either true or false. The mkdir function returns boolean value. If a directory is successfully created, then it returns true, otherwise it returns false.

Example

<?php
    $dir = mkdir('compound', '0777', true);
    if($dir) {
      echo 'Directory created successfully.';
    }
?>

Output -

Directory created successfully.



Related PHP Functions

PHP array_reverse() function
PHP array_diff() function
PHP array_key_exists() function
PHP array_push() function
PHP array_search() function
PHP class_exists() function
PHP curl_setopt() function
PHP die() function
PHP dirname() function
PHP each() function
PHP explode() function
PHP file_exists() function
PHP function_exists() function
PHP getenv() function
PHP is_readable() function
PHP ksort() function
PHP mkdir() function
PHP ob_start() function
PHP parse_url() function
PHP str_repeat() function
PHP substr() function




Read more articles


General Knowledge



Learn Popular Language