(PHP 4, PHP 5, PHP 7)
mkdir — 新建目录
$pathname
   [, int $mode = 0777
   [, bool $recursive = false
   [, resource $context
  ]]] )尝试新建一个由 pathname 指定的目录。
pathname目录的路径。
mode默认的 mode 是 0777,意味着最大可能的访问权。有关 mode 的更多信息请阅读 chmod() 页面。
Note:
mode在 Windows 下被忽略。
注意也许想用八进制数指定模式,也就是说该数应以零打头。模式也会被当前的 umask 修改,可以用 umask() 来改变。
recursive
       Allows the creation of nested directories specified in the 
       pathname.
      
contextNote: 在 PHP 5.0.0 中增加了对上下文(Context)的支持。有关上下文(Context)的说明参见 Streams。
   成功时返回 TRUE, 或者在失败时返回 FALSE。
  
| 版本 | 说明 | 
|---|---|
| 5.0.0 | 
        添加 recursive 参数。
        | 
      
| 5.0.0 | mkdir() 也可用于某些 URL 封装协议。参见支持的协议和封装协议 的列表看看 mkdir() 支持哪些 URL 封装协议。 | 
| 4.2.0 | 
        mode 成为可选项。
        | 
      
Example #1 mkdir() 例子
<?php
mkdir("/path/to/my/dir", 0700);
?>
Example #2 通过 recursive 参数使用 mkdir()
<?php
// Desired folder structure
$structure = './depth1/depth2/depth3/';
// To create the nested structure, the $recursive parameter 
// to mkdir() must be specified.
if (!mkdir($structure, 0, true)) {
    die('Failed to create folders...');
}
// ...
?>
Note: 当启用 安全模式时, PHP 会在执行脚本时检查被脚本操作的目录是否与被执行的脚本有相同的 UID(所有者)。