Home  >  Article  >  Backend Development  >  How to use php mkdir function

How to use php mkdir function

藏色散人
藏色散人Original
2019-02-20 15:01:323955browse

php The mkdir function is used to create a new directory. The syntax of this function is "mkdir(path, mode, recursive, context)". Its parameter "path" represents the name of the directory to be created. The parameter "mode" ” specifies permissions, and the parameter “recursive” specifies setting the recursive mode.

How to use php mkdir function

Recommendation: "PHP Video Tutorial"

mkdir() function uses the specified path name to create a new directory. The syntax is mkdir(path,mode,recursive,context), which takes the path and mode as parameters and returns TRUE on success and FALSE on failure. Note: The mode parameter in the mkdir() function is ignored on Windows platforms.

php How to use the mkdir() function?

Function: Create a directory.

Syntax:

mkdir(path,mode,recursive,context)

Parameters:

path: required. Specifies the name of the directory to be created.

mode: Required. Specify permissions. The default is 0777.

recursive: Required. Specifies whether to set recursive mode.

context: Required. Specifies the environment for a file handle. Context is a set of options that modify the behavior of the stream.

Description: Try to create a new directory specified by path. The default mode is 0777, which means maximum possible access.

php mkdir() function example

<?php
$dir = mkdir("newFile");
if($dir)
{
    echo "目录创建成功";
}else{
    echo "目录创建失败";
}
?>

This article is an introduction to the PHP mkdir function. I hope it will be helpful to friends in need!

The above is the detailed content of How to use php mkdir function. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn