reference/filesystem/functions/dirname.xml
67ca0d930c95a85ea49aff456409409f6ae06c1b
...
...
@@ -27,9 +27,16 @@
27
27
</note>
28
28
<caution>
29
29
<para>
30
-
<function>dirname</function> is locale aware, so for it to see the
31
-
correct directory name with multibyte character paths, the matching locale must
32
-
be set using the <function>setlocale</function> function.
30
+
On Windows, <function>dirname</function> assumes the currently set codepage, so for it to see the
31
+
correct directory name with multibyte character paths, the matching codepage must
32
+
be set.
33
+
If <parameter>path</parameter> contains characters which are invalid for the
34
+
current codepage, the behavior of <function>dirname</function> is undefined.
35
+
</para>
36
+
<para>
37
+
On other systems, <function>dirname</function> assumes <parameter>path</parameter>
38
+
to be encoded in an ASCII compatible encoding. Otherwise the behavior of the
39
+
the function is undefined.
33
40
</para>
34
41
</caution>
35
42
</refsect1>
...
...
@@ -75,6 +82,25 @@
75
82
<parameter>path</parameter> with any trailing
76
83
<literal>/component</literal> removed.
77
84
</para>
85
+

86
+
<caution>
87
+
<para>
88
+
Be careful when using this function in a loop that can reach the
89
+
top-level directory as this can result in an infinite loop.
90
+
<informalexample>
91
+
<programlisting role="php">
92
+
<![CDATA[
93
+
<?php
94
+
dirname('.'); // Will return '.'.
95
+
dirname('/'); // Will return `\` on Windows and '/' on *nix systems.
96
+
dirname('\\'); // Will return `\` on Windows and '.' on *nix systems.
97
+
dirname('C:\\'); // Will return 'C:\' on Windows and '.' on *nix systems.
98
+
?>
99
+
]]>
100
+
</programlisting>
101
+
</informalexample>
102
+
</para>
103
+
</caution>
78
104
</refsect1>
79
105

80
106
<refsect1 role="changelog">
...
...
@@ -95,12 +121,6 @@
95
121
Added the optional <parameter>levels</parameter> parameter.
96
122
</entry>
97
123
</row>
98
-
<row>
99
-
<entry>5.0.0</entry>
100
-
<entry>
101
-
<function>dirname</function> is now binary safe
102
-
</entry>
103
-
</row>
104
124
</tbody>
105
125
</tgroup>
106
126
</informaltable>
107
127