reference/filesystem/functions/dirname.xml
21cd3a942724400765125b657d24f8c8c4d623e9
...
...
@@ -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
39
+
the function is undefined.
33
40
</para>
34
41
</caution>
35
42
</refsect1>
...
...
@@ -75,36 +82,25 @@
75
82
<parameter>path</parameter> with any trailing
76
83
<literal>/component</literal> removed.
77
84
</para>
78
-
</refsect1>
79
85

80
-
<refsect1 role="changelog">
81
-
&reftitle.changelog;
82
-
<para>
83
-
<informaltable>
84
-
<tgroup cols="2">
85
-
<thead>
86
-
<row>
87
-
<entry>&Version;</entry>
88
-
<entry>&Description;</entry>
89
-
</row>
90
-
</thead>
91
-
<tbody>
92
-
<row>
93
-
<entry>7.0.0</entry>
94
-
<entry>
95
-
Added the optional <parameter>levels</parameter> parameter.
96
-
</entry>
97
-
</row>
98
-
<row>
99
-
<entry>5.0.0</entry>
100
-
<entry>
101
-
<function>dirname</function> is now binary safe
102
-
</entry>
103
-
</row>
104
-
</tbody>
105
-
</tgroup>
106
-
</informaltable>
107
-
</para>
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>
108
104
</refsect1>
109
105

110
106
<refsect1 role="examples">
111
107