mkdir
(PHP 4, PHP 5)
mkdir — Makes directory
說明
Attempts to create the directory specified by pathname.
參數
- pathname
-
The directory path.
- mode
-
The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the chmod() page.
Note: mode is ignored on Windows.
Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().
- recursive
-
- context
-
Note: 對 context 的支援是 PHP 5.0.0 增加的。有關 context 的說明見Streams。
Return值
如果成功則回傳 TRUE,失敗則回傳 FALSE。
更新日誌
版本 | 說明 |
---|---|
5.0.0 | The recursive parameter was added |
5.0.0 | As of PHP 5.0.0 mkdir() can also be used with some URL wrappers. Refer to List of Supported Protocols/Wrappers for a listing of which wrappers support mkdir() |
4.2.0 | The mode parameter became optional. |
範例
Example#1 mkdir() example
<?php
mkdir("/path/to/my/dir", 0700);
?>
註釋
Note: 當安全模式被啟用時,PHP 將檢查被操作的目錄是否和正在執行的腳本有相同的 UID(擁有者)。