2010-03-28 22:10:10 +00:00
<?xml version="1.0" encoding="utf-8"?>
2009-07-11 07:05:15 +00:00
<!-- $Revision$ -->
2007-06-20 22:25:43 +00:00
<refentry xmlns= "http://docbook.org/ns/docbook" xml:id= "function.mkdir" >
2007-02-03 08:13:44 +00:00
<refnamediv >
<refname > mkdir</refname>
<refpurpose > Makes directory</refpurpose>
</refnamediv>
2007-06-16 01:17:14 +00:00
<refsect1 role= "description" >
&reftitle.description;
2007-02-03 08:13:44 +00:00
<methodsynopsis >
<type > bool</type> <methodname > mkdir</methodname>
<methodparam > <type > string</type> <parameter > pathname</parameter> </methodparam>
2009-01-16 16:14:26 +00:00
<methodparam choice= "opt" > <type > int</type> <parameter > mode</parameter> <initializer > 0777</initializer> </methodparam>
<methodparam choice= "opt" > <type > bool</type> <parameter > recursive</parameter> <initializer > false</initializer> </methodparam>
2007-02-03 08:13:44 +00:00
<methodparam choice= "opt" > <type > resource</type> <parameter > context</parameter> </methodparam>
</methodsynopsis>
<para >
2013-12-11 00:45:52 +00:00
Attempts to create the directory specified by pathname. The directory must not already exist, and the relevant permissions must permit this. An E_WARNING level error will be generated on failure.
2007-02-03 08:13:44 +00:00
</para>
2007-06-16 01:17:14 +00:00
</refsect1>
<refsect1 role= "parameters" >
&reftitle.parameters;
2007-02-03 08:13:44 +00:00
<para >
2007-06-16 01:17:14 +00:00
<variablelist >
<varlistentry >
<term > <parameter > pathname</parameter> </term>
<listitem >
<para >
The directory path.
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > mode</parameter> </term>
<listitem >
<para >
The mode is 0777 by default, which means the widest possible
access. For more information on modes, read the details
on the <function > chmod</function> page.
</para>
<note >
<para >
<parameter > mode</parameter> is ignored on Windows.
</para>
</note>
<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
<function > umask</function> .
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > recursive</parameter> </term>
<listitem >
<para >
2010-03-02 01:50:22 +00:00
Allows the creation of nested directories specified in the
2012-03-27 18:53:04 +00:00
<parameter > pathname</parameter> .
2007-06-16 01:17:14 +00:00
</para>
</listitem>
</varlistentry>
<varlistentry >
<term > <parameter > context</parameter> </term>
<listitem >
¬e.context-support;
</listitem>
</varlistentry>
</variablelist>
2007-02-03 08:13:44 +00:00
</para>
2007-06-16 01:17:14 +00:00
</refsect1>
<refsect1 role= "returnvalues" >
&reftitle.returnvalues;
2007-02-03 08:13:44 +00:00
<para >
2007-06-16 01:17:14 +00:00
&return.success;
2007-02-03 08:13:44 +00:00
</para>
2007-06-16 01:17:14 +00:00
</refsect1>
<refsect1 role= "changelog" >
&reftitle.changelog;
<para >
<informaltable >
<tgroup cols= "2" >
<thead >
<row >
<entry > &Version; </entry>
<entry > &Description; </entry>
</row>
</thead>
<tbody >
<row >
<entry > 5.0.0</entry>
<entry >
The <parameter > recursive</parameter> parameter was added
</entry>
</row>
<row >
<entry > 5.0.0</entry>
<entry >
As of PHP 5.0.0 <function > mkdir</function> can also be used with
<emphasis > some</emphasis> URL wrappers. Refer to <xref
linkend="wrappers"/> for a listing of which wrappers support
<function > mkdir</function>
</entry>
</row>
<row >
<entry > 4.2.0</entry>
<entry >
The <parameter > mode</parameter> parameter became optional.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role= "examples" >
&reftitle.examples;
2007-02-03 08:13:44 +00:00
<para >
<example >
2007-06-16 01:17:14 +00:00
<title > <function > mkdir</function> example</title>
2007-02-03 08:13:44 +00:00
<programlisting role= "php" >
2002-04-15 00:12:54 +00:00
< ![CDATA[
2003-05-30 20:43:26 +00:00
< ?php
2003-12-15 16:55:22 +00:00
mkdir("/path/to/my/dir", 0700);
2003-05-30 20:43:26 +00:00
?>
2010-03-02 01:50:22 +00:00
]]>
</programlisting>
</example>
</para>
<para >
<example >
<title > <function > mkdir</function> using the <parameter > recursive</parameter> parameter</title>
<programlisting role= "php" >
< ![CDATA[
< ?php
2010-04-05 13:45:14 +00:00
// Desired folder structure
2010-03-02 01:50:22 +00:00
$structure = './depth1/depth2/depth3/';
2010-04-05 13:45:14 +00:00
// To create the nested structure, the $recursive parameter
// to mkdir() must be specified.
2010-03-02 01:50:22 +00:00
2010-04-05 13:45:14 +00:00
if (!mkdir($structure, 0, true)) {
2010-03-22 16:07:38 +00:00
die('Failed to create folders...');
2010-03-02 01:50:22 +00:00
}
2010-04-05 13:45:14 +00:00
// ...
2010-03-02 01:50:22 +00:00
?>
2002-04-15 00:12:54 +00:00
]]>
2007-02-03 08:13:44 +00:00
</programlisting>
</example>
</para>
2007-06-16 01:17:14 +00:00
</refsect1>
<refsect1 role= "notes" >
&reftitle.notes;
2007-02-03 08:13:44 +00:00
¬e.sm.uidcheck.dir;
2007-06-16 01:17:14 +00:00
</refsect1>
<refsect1 role= "seealso" >
&reftitle.seealso;
2007-02-03 08:13:44 +00:00
<para >
2007-06-16 01:17:14 +00:00
<simplelist >
2010-03-27 02:40:32 +00:00
<member > <function > is_dir</function> </member>
2007-06-16 01:17:14 +00:00
<member > <function > rmdir</function> </member>
</simplelist>
2007-02-03 08:13:44 +00:00
</para>
</refsect1>
2007-06-16 01:17:14 +00:00
2007-02-03 08:13:44 +00:00
</refentry>
2002-04-15 00:12:54 +00:00
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
2009-09-25 07:04:39 +00:00
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
2002-04-15 00:12:54 +00:00
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->