目录

PHP mkdir() 函数

❮ PHP 文件系统参考

示例

创建一个名为"test"的目录:

<?php
mkdir("test");
?>


定义和用法

mkdir() 函数创建由路径名指定的目录。

语法

mkdir( path, mode, recursive, context)

参数值

Parameter Description
path Required. Specifies the directory path to create
mode Optional. Specifies permissions. By default, the mode is 0777 (widest possible access).

Note: The mode parameters is ignored on Windows platforms!

The mode parameter consists of four numbers:

  • The first number is always zero
  • The second number specifies permissions for the owner
  • The third number specifies permissions for the owner's user group
  • The fourth number specifies permissions for everybody else

Possible values (to set multiple permissions, add up the following numbers):

  • 1 = execute permissions
  • 2 = write permissions
  • 4 = read permissions
recursive Optional. Specifies if the recursive mode is set (added in PHP 5)
context Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream (added in PHP 5)

技术细节

返回值: TRUE 成功,FALSE 失败
PHP 版本: 4.0+

❮ PHP 文件系统参考