reference/spl/directoryiterator/getextension.xml
62126c55f1c6ed444043e7272c4f9e233818a44b
...
...
@@ -1,24 +1,21 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<refentry xml:id="directoryiterator.getextension" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
<refnamediv>
6
5
<refname>DirectoryIterator::getExtension</refname>
7
-
<refpurpose>Returns the file extension component of path</refpurpose>
6
+
<refpurpose>Gets the file extension</refpurpose>
8
7
</refnamediv>
9
8

10
9
<refsect1 role="description">
11
10
&reftitle.description;
12
-
<methodsynopsis>
11
+
<methodsynopsis role="DirectoryIterator">
13
12
<modifier>public</modifier> <type>string</type><methodname>DirectoryIterator::getExtension</methodname>
14
-
<void />
13
+
<void/>
15
14
</methodsynopsis>
16
15
<para>
17
-

16
+
Retrieves the file extension.
18
17
</para>
19
18

20
-
&warn.undocumented.func;
21
-

22
19
</refsect1>
23
20

24
21
<refsect1 role="parameters">
...
...
@@ -29,13 +26,70 @@
29
26
<refsect1 role="returnvalues">
30
27
&reftitle.returnvalues;
31
28
<para>
32
-

29
+
Returns a <type>string</type> containing the file extension, or an
30
+
empty <type>string</type> if the file has no extension.
33
31
</para>
34
32
</refsect1>
35
33

34
+
<refsect1 role="examples">
35
+
&reftitle.examples;
36
+
<example>
37
+
<title><function>DirectoryIterator::getExtension</function> example</title>
38
+
<programlisting role="php">
39
+
<![CDATA[
40
+
<?php
36
41

37
-
</refentry>
42
+
$directory = new DirectoryIterator(__DIR__);
43
+
foreach ($directory as $fileinfo) {
44
+
if ($fileinfo->isFile()) {
45
+
echo $fileinfo->getExtension() . "\n";
46
+
}
47
+
}
48
+

49
+
?>
50
+
]]>
51
+
</programlisting>
52
+
&example.outputs.similar;
53
+
<screen>
54
+
<![CDATA[
55
+
php
56
+
txt
57
+
jpg
58
+
gz
59
+
]]>
60
+
</screen>
61
+
</example>
62
+
</refsect1>
63
+

64
+
<refsect1 role="notes">
65
+
&reftitle.notes;
66
+
<note>
67
+
<para>
68
+
Another way of getting the extension is to use the
69
+
<function>pathinfo</function> function.
70
+
</para>
71
+
<informalexample>
72
+
<programlisting role="php">
73
+
<![CDATA[
74
+
<?php
75
+
$extension = pathinfo($fileinfo->getFilename(), PATHINFO_EXTENSION);
76
+
?>
77
+
]]>
78
+
</programlisting>
79
+
</informalexample>
80
+
</note>
81
+
</refsect1>
38
82

83
+
<refsect1 role="seealso">
84
+
&reftitle.seealso;
85
+
<simplelist>
86
+
<member><methodname>DirectoryIterator::getFilename</methodname></member>
87
+
<member><methodname>DirectoryIterator::getBasename</methodname></member>
88
+
<member><function>pathinfo</function></member>
89
+
</simplelist>
90
+
</refsect1>
91
+

92
+
</refentry>
39
93
<!-- Keep this comment at the end of the file
40
94
Local variables:
41
95
mode: sgml
42
96