reference/filesystem/functions/pathinfo.xml
d0cc084a925f112c156d0dbac12718b2bd8d4889
...
...
@@ -1,6 +1,6 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.pathinfo">
3
+
<refentry xml:id="function.pathinfo" xmlns="http://docbook.org/ns/docbook">
4
4
<refnamediv>
5
5
<refname>pathinfo</refname>
6
6
<refpurpose>Returns information about a file path</refpurpose>
...
...
@@ -9,14 +9,14 @@
9
9
<refsect1 role="description">
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
-
<type>mixed</type><methodname>pathinfo</methodname>
12
+
<type class="union"><type>array</type><type>string</type></type><methodname>pathinfo</methodname>
13
13
<methodparam><type>string</type><parameter>path</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME</initializer></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer><constant>PATHINFO_ALL</constant></initializer></methodparam>
15
15
</methodsynopsis>
16
16
<para>
17
17
<function>pathinfo</function> returns information about
18
18
<parameter>path</parameter>: either an associative array or a string,
19
-
depending on <parameter>options</parameter>.
19
+
depending on <parameter>flags</parameter>.
20
20
</para>
21
21
<note>
22
22
<para>
...
...
@@ -25,6 +25,20 @@
25
25
predefined reserved variables</link>.
26
26
</para>
27
27
</note>
28
+
<note>
29
+
<para>
30
+
<function>pathinfo</function> operates naively on the input string,
31
+
and is not aware of the actual filesystem, or path components such
32
+
as "<literal>..</literal>".
33
+
</para>
34
+
</note>
35
+
<note>
36
+
<para>
37
+
On Windows systems only, the <literal>\</literal> character will
38
+
be interpreted as a directory separator. On other systems it will
39
+
be treated like any other character.
40
+
</para>
41
+
</note>
28
42
<caution>
29
43
<para>
30
44
<function>pathinfo</function> is locale aware, so for it to parse a path
...
...
@@ -47,7 +61,7 @@
47
61
</listitem>
48
62
</varlistentry>
49
63
<varlistentry>
50
-
<term><parameter>options</parameter></term>
64
+
<term><parameter>flags</parameter></term>
51
65
<listitem>
52
66
<para>
53
67
If present, specifies a specific element to be returned; one of
...
...
@@ -56,7 +70,7 @@
56
70
<constant>PATHINFO_EXTENSION</constant> or
57
71
<constant>PATHINFO_FILENAME</constant>.
58
72
</para>
59
-
<para>If <parameter>options</parameter> is not specified, returns all
73
+
<para>If <parameter>flags</parameter> is not specified, returns all
60
74
available elements.
61
75
</para>
62
76
</listitem>
...
...
@@ -68,7 +82,7 @@
68
82
<refsect1 role="returnvalues">
69
83
&reftitle.returnvalues;
70
84
<para>
71
-
If the <parameter>options</parameter> parameter is not passed, an
85
+
If the <parameter>flags</parameter> parameter is not passed, an
72
86
associative <type>array</type> containing the following elements is
73
87
returned:
74
88
<literal>dirname</literal>, <literal>basename</literal>,
...
...
@@ -98,35 +112,11 @@
98
112
</para>
99
113
</note>
100
114
<para>
101
-
If <parameter>options</parameter> is present, returns a
115
+
If <parameter>flags</parameter> is present, returns a
102
116
<type>string</type> containing the requested element.
103
117
</para>
104
118
</refsect1>
105
119

106
-
<refsect1 role="changelog">
107
-
&reftitle.changelog;
108
-
<para>
109
-
<informaltable>
110
-
<tgroup cols="2">
111
-
<thead>
112
-
<row>
113
-
<entry>&Version;</entry>
114
-
<entry>&Description;</entry>
115
-
</row>
116
-
</thead>
117
-
<tbody>
118
-
<row>
119
-
<entry>5.2.0</entry>
120
-
<entry>
121
-
The <constant>PATHINFO_FILENAME</constant> constant was added.
122
-
</entry>
123
-
</row>
124
-
</tbody>
125
-
</tgroup>
126
-
</informaltable>
127
-
</para>
128
-
</refsect1>
129
-

130
120
<refsect1 role="examples">
131
121
&reftitle.examples;
132
122
<para>
...
...
@@ -140,7 +130,7 @@ $path_parts = pathinfo('/www/htdocs/inc/lib.inc.php');
140
130
echo $path_parts['dirname'], "\n";
141
131
echo $path_parts['basename'], "\n";
142
132
echo $path_parts['extension'], "\n";
143
-
echo $path_parts['filename'], "\n"; // since PHP 5.2.0
133
+
echo $path_parts['filename'], "\n";
144
134
?>
145
135
]]>
146
136
</programlisting>
...
...
@@ -204,6 +194,32 @@ Array
204
194
</screen>
205
195
</example>
206
196
</para>
197
+
<para>
198
+
<example>
199
+
<title><function>pathinfo</function> example with array dereferencing</title>
200
+
<para>
201
+
The <parameter>flags</parameter> parameter is not a bitmask. Only a single value
202
+
may be provided. To select only a limited set of parsed values, use array
203
+
destructuring like so:
204
+
</para>
205
+
<programlisting role="php">
206
+
<![CDATA[
207
+
<?php
208
+
['basename' => $basename, 'dirname' => $dirname] = pathinfo('/www/htdocs/inc/lib.inc.php');
209
+

210
+
var_dump($basename, $dirname);
211
+
?>
212
+
]]>
213
+
</programlisting>
214
+
&example.outputs.similar;
215
+
<screen>
216
+
<![CDATA[
217
+
string(11) "lib.inc.php"
218
+
string(15) "/www/htdocs/inc"
219
+
]]>
220
+
</screen>
221
+
</example>
222
+
</para>
207
223
</refsect1>
208
224

209
225
<refsect1 role="seealso">
...
...
@@ -219,7 +235,6 @@ Array
219
235
</refsect1>
220
236

221
237
</refentry>
222
-

223
238
<!-- Keep this comment at the end of the file
224
239
Local variables:
225
240
mode: sgml
226
241