mkdir 函数
PHP mkdir()函数 (PHP mkdir() function)
The full form of mkdir is "Make Directory", the function mkdir() is used to create a directory.
mkdir的完整格式为“ Make Directory” , 函数mkdir()用于创建目录。
Syntax:
句法:
mkdir(dir_path, access_mode, recursive, context);
Parameter(s):
参数:
dir_path – It defines the path to the directory, where we want to create a directory.
dir_path –它定义了我们要在其中创建目录的目录路径。
access_mode – It is an optional parameter; its default value is 0777 that stands for the widest possible access. There are 4 values to be set for the access mode,
- The first value should be 0
- The second value sets the permission for the owner
- The third value sets the permission for the owner's user group
- The fourth value sets the permission for everybody else
-
access_mode –是可选参数; 其默认值为0777 ,表示可能的最大访问范围。 存取模式需要设定4个值,
- 第一个值应为0
- 第二个值设置所有者的权限
- 第三个值设置所有者用户组的权限
- 第四个值设置其他所有人的权限
recursive – It is also an optional parameter; It defines the recursive mode.
递归 –也是可选参数; 它定义了递归模式。
context - It is also an optional parameter; It sets the context (a set of options that can modify the behavior of a stream) of the file handling.
context-它也是一个可选参数; 它设置文件处理的上下文(一组可以修改流行为的选项)。
Return value:
返回值:
It returns a Boolean value, "TRUE" – if the directory creates successfully or "FALSE" – if the directory does not create.
如果目录创建成功,则返回布尔值“ TRUE”;如果目录未创建,则返回“ FALSE”。
Example: PHP code to create directory
示例:创建目录PHP代码
<?php
//creating the directory
$ret_value = mkdir("/home/folder1");
if ($ret_value == true)
echo "directory created successfully...";
else
echo "directory is not created successfully...";
?>
Output
输出量
directory created successfully...
Reference: PHP mkdir() function
参考: PHP mkdir()函数
翻译自: https://www.includehelp.com/php/mkdir-function-with-example.aspx
mkdir 函数