reference/filesystem/functions/mkdir.xml
6b48028aef8211f89ae6c9fefe64177de2f86e12
...
...
@@ -10,13 +10,13 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>bool</type><methodname>mkdir</methodname>
13
-
<methodparam><type>string</type><parameter>pathname</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>0777</initializer></methodparam>
13
+
<methodparam><type>string</type><parameter>directory</parameter></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>permissions</parameter><initializer>0777</initializer></methodparam>
15
15
<methodparam choice="opt"><type>bool</type><parameter>recursive</parameter><initializer>&false;</initializer></methodparam>
16
-
<methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam>
16
+
<methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>context</parameter><initializer>&null;</initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
-
Attempts to create the directory specified by pathname.
19
+
Attempts to create the directory specified by <parameter>directory</parameter>.
20
20
</para>
21
21
</refsect1>
22
22

...
...
@@ -25,29 +25,30 @@
25
25
<para>
26
26
<variablelist>
27
27
<varlistentry>
28
-
<term><parameter>pathname</parameter></term>
28
+
<term><parameter>directory</parameter></term>
29
29
<listitem>
30
30
<para>
31
31
The directory path.
32
+
&tip.fopen-wrapper;
32
33
</para>
33
34
</listitem>
34
35
</varlistentry>
35
36
<varlistentry>
36
-
<term><parameter>mode</parameter></term>
37
+
<term><parameter>permissions</parameter></term>
37
38
<listitem>
38
39
<para>
39
-
The mode is 0777 by default, which means the widest possible
40
-
access. For more information on modes, read the details
40
+
The permissions are 0777 by default, which means the widest possible
41
+
access. For more information on permissions, read the details
41
42
on the <function>chmod</function> page.
42
43
</para>
43
44
<note>
44
45
<para>
45
-
<parameter>mode</parameter> is ignored on Windows.
46
+
<parameter>permissions</parameter> is ignored on Windows.
46
47
</para>
47
48
</note>
48
49
<para>
49
-
Note that you probably want to specify the mode as an octal number,
50
-
which means it should have a leading zero. The mode is also modified
50
+
Note that you probably want to specify the <parameter>permissions</parameter> as an octal number,
51
+
which means it should have a leading zero. The <parameter>permissions</parameter> is also modified
51
52
by the current umask, which you can change using
52
53
<function>umask</function>.
53
54
</para>
...
...
@@ -57,8 +58,8 @@
57
58
<term><parameter>recursive</parameter></term>
58
59
<listitem>
59
60
<para>
60
-
Allows the creation of nested directories specified in the
61
-
<parameter>pathname</parameter>.
61
+
If &true;, then any parent directories to the <parameter>directory</parameter> specified will
62
+
also be created, with the same permissions.
62
63
</para>
63
64
</listitem>
64
65
</varlistentry>
...
...
@@ -77,6 +78,26 @@
77
78
<para>
78
79
&return.success;
79
80
</para>
81
+
<note>
82
+
<para>
83
+
If the directory to be created already exists, that is considered an error
84
+
and &false; will still be returned. Use <function>is_dir</function> or
85
+
<function>file_exists</function> to check if the directory already exists
86
+
before trying to create it.
87
+
</para>
88
+
</note>
89
+
</refsect1>
90
+

91
+
<refsect1 role="errors">
92
+
&reftitle.errors;
93
+
<para>
94
+
Emits an <constant>E_WARNING</constant> level error if the directory
95
+
already exists.
96
+
</para>
97
+
<para>
98
+
Emits an <constant>E_WARNING</constant> level error if the relevant
99
+
permissions prevent creating the directory.
100
+
</para>
80
101
</refsect1>
81
102

82
103
<refsect1 role="examples">
...
...
@@ -99,14 +120,14 @@ mkdir("/path/to/my/dir", 0700);
99
120
<programlisting role="php">
100
121
<![CDATA[
101
122
<?php
102
-
// Desired folder structure
123
+
// Desired directory structure
103
124
$structure = './depth1/depth2/depth3/';
104
125

105
126
// To create the nested structure, the $recursive parameter
106
127
// to mkdir() must be specified.
107
128

108
129
if (!mkdir($structure, 0777, true)) {
109
-
die('Failed to create folders...');
130
+
die('Failed to create directories...');
110
131
}
111
132

112
133
// ...
...
...
@@ -117,29 +138,13 @@ if (!mkdir($structure, 0777, true)) {
117
138
</para>
118
139
</refsect1>
119
140

120
-
<refsect1 role="errors">
121
-
&reftitle.errors;
122
-
<para>
123
-
Emits an <constant>E_WARNING</constant> level error if the directory
124
-
already exists.
125
-
</para>
126
-
<para>
127
-
Emits an <constant>E_WARNING</constant> level error if the relevant
128
-
permissions prevent creating the directory.
129
-
</para>
130
-
</refsect1>
131
-

132
-
<refsect1 role="notes">
133
-
&reftitle.notes;
134
-
&note.sm.uidcheck.dir;
135
-
</refsect1>
136
-

137
141
<refsect1 role="seealso">
138
142
&reftitle.seealso;
139
143
<para>
140
144
<simplelist>
141
145
<member><function>is_dir</function></member>
142
146
<member><function>rmdir</function></member>
147
+
<member><function>umask</function></member>
143
148
</simplelist>
144
149
</para>
145
150
</refsect1>
146
151