📄 function.mkdir.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Makes directory</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.lstat.html">lstat</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.move-uploaded-file.html">move_uploaded_file</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.mkdir" class="refentry"> <div class="refnamediv"> <h1 class="refname">mkdir</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">mkdir</span> — <span class="dc-title">Makes directory</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">bool</span> <span class="methodname"><b><b>mkdir</b></b></span> ( <span class="methodparam"><span class="type">string</span> <tt class="parameter">$pathname</tt></span> [, <span class="methodparam"><span class="type">int</span> <tt class="parameter">$mode</tt></span> [, <span class="methodparam"><span class="type">bool</span> <tt class="parameter">$recursive</tt></span> [, <span class="methodparam"><span class="type">resource</span> <tt class="parameter">$context</tt></span> ]]] )</div> <p class="para rdfs-comment"> Attempts to create the directory specified by pathname. </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">pathname</tt></i></span> <dd> <p class="para"> The directory path. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">mode</tt></i></span> <dd> <p class="para"> The mode is 0777 by default, which means the widest possible access. For more information on modes, read the details on the <a href="function.chmod.html" class="function">chmod()</a> page. </p> <blockquote><p><b class="note">Note</b>: <i><tt class="parameter">mode</tt></i> is ignored on Windows. <br /> </p></blockquote> <p class="para"> 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 <a href="function.umask.html" class="function">umask()</a>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">recursive</tt></i></span> <dd> <p class="para"> Default to <b><tt>FALSE</tt></b>. </p> </dd> </dt> <dt> <span class="term"><i><tt class="parameter">context</tt></i></span> <dd> <blockquote><p><b class="note">Note</b>: <span class="simpara">Context support was addedwith PHP 5.0.0. For a description of <i>contexts</i>, refer to<a href="ref.stream.html" class="xref">Stream Functions</a>.</span></p></blockquote> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns <b><tt>TRUE</tt></b> on success or <b><tt>FALSE</tt></b> on failure. </p> </div> <div class="refsect1 changelog"> <h3 class="title">ChangeLog</h3> <p class="para"> <table class="informaltable"> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Version</th> <th colspan="1">Description</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.0</td> <td colspan="1" rowspan="1" align="left"> The <i><tt class="parameter">recursive</tt></i> parameter was added </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">5.0.0</td> <td colspan="1" rowspan="1" align="left"> As of PHP 5.0.0 <b>mkdir()</b> can also be used with <em class="emphasis">some</em> URL wrappers. Refer to <a href="wrappers.html" class="xref">List of Supported Protocols/Wrappers</a> for a listing of which wrappers support <b>mkdir()</b> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">4.2.0</td> <td colspan="1" rowspan="1" align="left"> The <i><tt class="parameter">mode</tt></i> parameter became optional. </td> </tr> </tbody> </colgroup> </table> </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>mkdir()</b> example</b></p> <div class="example-contents"><div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?php<br />mkdir</span><span style="color: #007700">(</span><span style="color: #DD0000">"/path/to/my/dir"</span><span style="color: #007700">, </span><span style="color: #0000BB">0700</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 notes"> <h3 class="title">Notes</h3> <blockquote><p><b class="note">Note</b>: <span class="simpara">When <a href="features.safe-mode.html" class="link">safe mode</a> is enabled, PHP checks whether the directory in which the script is operating has the same UID (owner) as the script that is being executed.</span></p></blockquote> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"><a href="function.rmdir.html" class="function" rel="rdfs-seeAlso">rmdir()</a></li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.lstat.html">lstat</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.move-uploaded-file.html">move_uploaded_file</a></div> <div class="up"><a href="ref.filesystem.html">Filesystem Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -