-
Notifications
You must be signed in to change notification settings - Fork 49
/
pathinfo.xml
243 lines (232 loc) · 6.51 KB
/
pathinfo.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 23348cb918016e0da9a346d1b65f316696fad6cd Maintainer: seros Status: ready -->
<!-- Reviewed: no -->
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.pathinfo">
<refnamediv>
<refname>pathinfo</refname>
<refpurpose>Devuelve información acerca de la ruta de un fichero</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>mixed</type><methodname>pathinfo</methodname>
<methodparam><type>string</type><parameter>path</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>PATHINFO_DIRNAME | PATHINFO_BASENAME | PATHINFO_EXTENSION | PATHINFO_FILENAME</initializer></methodparam>
</methodsynopsis>
<para>
<function>pathinfo</function> devuelve información acerca de
<parameter>path</parameter>: bien como un array asociativo, o bien como un string,
en función del valor de <parameter>options</parameter>.
</para>
<note>
<para>
Para infomación sobre la recuperación de la información de la ruta actual, lea
la sección sobre <link linkend="language.variables.predefined">
variables reservadas predefinidas</link>.
</para>
</note>
<caution>
<para>
<function>pathinfo</function> tiene en cuenta la configuración regional, por lo que, para analizar
una ruta que contiene caracteres multibyte correctamente, se debe establecer la configuración regional
correspondiente usando la función <function>setlocale</function>.
</para>
</caution>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>path</parameter></term>
<listitem>
<para>
La ruta a analizar.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>options</parameter></term>
<listitem>
<para>
Si está presente, indica qué elementos específicos se devuelven, de entre
<constant>PATHINFO_DIRNAME</constant>,
<constant>PATHINFO_BASENAME</constant>,
<constant>PATHINFO_EXTENSION</constant> y
<constant>PATHINFO_FILENAME</constant>.
</para>
<para>Si no se especifica <parameter>options</parameter>, se devuelven todos
los elementos disponibles.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Si no se proporciona el parámetro <parameter>options</parameter>, se
devuelve un <type>array</type> asociativo que contiene los siguientes
elementos:
<literal>dirname</literal>, <literal>basename</literal>,
<literal>extension</literal> (si tiene), y <literal>filename</literal>.
</para>
<note>
<para>
Si <parameter>path</parameter> tiene más de una extensión,
<constant>PATHINFO_EXTENSION</constant> devuelve solamente la última, y
<constant>PATHINFO_FILENAME</constant> solamente quita la última.
(véase el primer ejemplo de más abajo).
</para>
</note>
<note>
<para>
Si <parameter>path</parameter> no tiene ninguna extensión, no
se devolverá ningún elemento <literal>extension</literal>
(véase el segundo ejemplo de más abajo).
</para>
</note>
<note>
<para>
Si <literal>basename</literal> de <parameter>path</parameter> comienza
con un punto, los siguientes caracteres serán interpretados como
<literal>extension</literal>, y <literal>filename</literal> estará vacío
(véase el tercer ejemplo más adelante).
</para>
</note>
<para>
Si <parameter>options</parameter> estuviera presente, se devolverá un
<type>string</type> que contiene el elemento solicitado.
</para>
</refsect1>
<refsect1 role="changelog">
&reftitle.changelog;
<para>
<informaltable>
<tgroup cols="2">
<thead>
<row>
<entry>&Version;</entry>
<entry>&Description;</entry>
</row>
</thead>
<tbody>
<row>
<entry>5.2.0</entry>
<entry>
Se añadió la constante <constant>PATHINFO_FILENAME</constant>.
</entry>
</row>
</tbody>
</tgroup>
</informaltable>
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title>Ejemplo de <function>pathinfo</function></title>
<programlisting role="php">
<![CDATA[
<?php
$partes_ruta = pathinfo('/www/htdocs/inc/lib.inc.php');
echo $partes_ruta['dirname'], "\n";
echo $partes_ruta['basename'], "\n";
echo $partes_ruta['extension'], "\n";
echo $partes_ruta['filename'], "\n"; // desde PHP 5.2.0
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
/www/htdocs/inc
lib.inc.php
php
lib.inc
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Ejemplo de <function>pathinfo</function> mostrando las diferencias entre null y no utilizar extensión</title>
<programlisting role="php">
<![CDATA[
<?php
$partes_ruta = pathinfo('/path/emptyextension.');
var_dump($partes_ruta['extension']);
$partes_ruta = pathinfo('/path/noextension');
var_dump($partes_ruta['extension']);
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
string(0) ""
Notice: Undefined index: extension in test.php on line 6
]]>
</screen>
</example>
</para>
<para>
<example>
<title>Ejemplo de <function>pathinfo</function> para un fichero que comienza con punto</title>
<programlisting role="php">
<![CDATA[
<?php
print_r(pathinfo('/una/ruta/.test'));
?>
]]>
</programlisting>
&example.outputs.similar;
<screen>
<![CDATA[
Array
(
[dirname] => /una/ruta
[basename] => .test
[extension] => test
[filename] =>
)
]]>
</screen>
</example>
</para>
</refsect1>
<refsect1 role="seealso">
&reftitle.seealso;
<para>
<simplelist>
<member><function>dirname</function></member>
<member><function>basename</function></member>
<member><function>parse_url</function></member>
<member><function>realpath</function></member>
</simplelist>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->