Home > Backend Development > PHP Tutorial > How to use php mkdir function

How to use php mkdir function

藏色散人
Release: 2023-04-05 10:54:01
Original
3968 people have browsed it

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)
Copy after login

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 "目录创建失败";
}
?>
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template