1
0
mirror of https://github.com/php/doc-es.git synced 2026-03-26 00:12:06 +01:00
Files
archived-doc-es/reference/filesystem/functions/pathinfo.xml
Pedro Antonio Gil Rodríguez a885506c8b Actualización a la últma versión
git-svn-id: https://svn.php.net/repository/phpdoc/es/trunk@331162 c90b9560-bf6c-de11-be94-00142212c4b1
2013-08-19 12:40:17 +00:00

216 lines
5.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: 33040b3b1b95210112f7b3b71f57a1c005de1a3b 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>
</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>
<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>
</refsect1>
<refsect1 role="notes">
&reftitle.notes;
<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>
<note>
<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>
</note>
</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
-->