mkdir 函数_PHP mkdir()函数与示例

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
    Note: The access_mode parameter is ignored on Windows system.
  • access_mode –是可选参数; 其默认值为0777 ,表示可能的最大访问范围。 存取模式需要设定4个值,

    • 第一个值应为0
    • 第二个值设置所有者的权限
    • 第三个值设置所有者用户组的权限
    • 第四个值设置其他所有人的权限
    注意:在Windows系统上,将忽略access_mode参数。
  • 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 函数

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值