<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.filesystem.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'es',
  ),
  'this' => 
  array (
    0 => 'function.pathinfo.php',
    1 => 'pathinfo',
    2 => 'Devuelve informaci&oacute;n sobre una ruta del sistema',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Funciones del Sistema de Archivos',
  ),
  'prev' => 
  array (
    0 => 'function.parse-ini-string.php',
    1 => 'parse_ini_string',
  ),
  'next' => 
  array (
    0 => 'function.pclose.php',
    1 => 'pclose',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'es',
    'path' => 'reference/filesystem/functions/pathinfo.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.pathinfo" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">pathinfo</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">pathinfo</span> &mdash; <span class="dc-title">Devuelve información sobre una ruta del sistema</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pathinfo-description">
  <h3 class="title">Descripción</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>pathinfo</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$path</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$flags</code><span class="initializer"> = <strong><code><a href="filesystem.constants.php#constant.pathinfo-all">PATHINFO_ALL</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>pathinfo()</strong></span> devuelve información sobre la ruta
   <code class="parameter">path</code>, en forma de string o array asociativo, dependiendo del argumento <code class="parameter">flags</code>.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Para más información sobre la lectura de la ruta actual,
    consulte la sección sobre las
    <a href="language.variables.predefined.php" class="link">variables predefinidas</a>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    <span class="function"><strong>pathinfo()</strong></span> opera de manera ingenua sobre la cadena de entrada,
    y no es consciente de los sistemas de archivos actuales, o de los componentes
    de rutas como &quot;<code class="literal">..</code>&quot;.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Solo en sistemas Windows, el carácter <code class="literal">\</code> será
    interpretado como separador de directorio. En otros sistemas, será
    tratado como cualquier otro carácter.
   </p>
  </p></blockquote>
  <div class="caution"><strong class="caution">Precaución</strong>
   <p class="para">
    La función <span class="function"><strong>pathinfo()</strong></span> es sensible a la configuración local,
    por lo tanto, si se desea que analice correctamente una ruta que contenga
    caracteres de varios bytes, la configuración local correspondiente debe ser definida
    utilizando la función <span class="function"><a href="function.setlocale.php" class="function">setlocale()</a></span>.
   </p>
  </div>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.pathinfo-parameters">
  <h3 class="title">Parámetros</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">path</code></dt>
     <dd>
      <p class="para">
       La ruta a analizar.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Especifica qué elemento será devuelto. Puede pasar una de las constantes
       <strong><code><a href="filesystem.constants.php#constant.pathinfo-dirname">PATHINFO_DIRNAME</a></code></strong>,
       <strong><code><a href="filesystem.constants.php#constant.pathinfo-basename">PATHINFO_BASENAME</a></code></strong>,
       <strong><code><a href="filesystem.constants.php#constant.pathinfo-extension">PATHINFO_EXTENSION</a></code></strong> y
       <strong><code><a href="filesystem.constants.php#constant.pathinfo-filename">PATHINFO_FILENAME</a></code></strong>.
      </p>
      <p class="para">
       Si <code class="parameter">flags</code> no es especificado,
       todos los elementos son devueltos.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pathinfo-returnvalues">
  <h3 class="title">Valores devueltos</h3>
  <p class="para">
   Si <code class="parameter">flags</code> no es utilizado, esta función devolverá
   un array asociativo que contiene los siguientes elementos :
   <code class="literal">dirname</code>, <code class="literal">basename</code>,
   <code class="literal">extension</code> (si existe), y <code class="literal">filename</code>.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Si <code class="parameter">path</code> contiene más de una extensión,
    <strong><code><a href="filesystem.constants.php#constant.pathinfo-extension">PATHINFO_EXTENSION</a></code></strong> devuelve únicamente la
    última y <strong><code><a href="filesystem.constants.php#constant.pathinfo-filename">PATHINFO_FILENAME</a></code></strong> eliminará
    únicamente la última también (ver el primer ejemplo a continuación).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
  <p class="para">
    Si <code class="parameter">path</code> no tiene extensión, el elemento
    <code class="literal">extension</code> no será devuelto
    (ver el segundo ejemplo a continuación).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <p class="para">
    Si <code class="literal">basename</code> del argumento <code class="parameter">path</code>
    comienza con un punto, los caracteres siguientes son interpretados como la
    <code class="literal">extension</code>, y el <code class="literal">filename</code> estará vacío
    (ver el tercer ejemplo a continuación).
   </p>
  </p></blockquote>
  <p class="para">
   Si <code class="parameter">flags</code> es utilizado, esta función devolverá
   una <span class="type"><a href="language.types.string.php" class="type string">string</a></span> que contiene los elementos.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pathinfo-examples">
  <h3 class="title">Ejemplos</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Ejemplo #1 Ejemplo con <span class="function"><strong>pathinfo()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$path_parts </span><span style="color: #007700">= </span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/www/htdocs/inc/lib.inc.php'</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'dirname'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'basename'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'extension'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />echo </span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'filename'</span><span style="color: #007700">], </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>El ejemplo anterior mostrará:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">/www/htdocs/inc
lib.inc.php
php
lib.inc</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Ejemplo #2 Ejemplo <span class="function"><strong>pathinfo()</strong></span> sin extensión</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$path_parts </span><span style="color: #007700">= </span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/emptyextension.'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'extension'</span><span style="color: #007700">]);<br /><br /></span><span style="color: #0000BB">$path_parts </span><span style="color: #007700">= </span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/path/noextension'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$path_parts</span><span style="color: #007700">[</span><span style="color: #DD0000">'extension'</span><span style="color: #007700">]);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Resultado del ejemplo anterior es similar a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">string(0) &quot;&quot;

Notice: Undefined index: extension in test.php on line 6
NULL</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Ejemplo #3 Ejemplo con <span class="function"><strong>pathinfo()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/some/path/.test'</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Resultado del ejemplo anterior es similar a:</p></div>
    <div class="example-contents screen">
<div class="examplescode"><pre class="examplescode">Array
(
    [dirname] =&gt; /some/path
    [basename] =&gt; .test
    [extension] =&gt; test
    [filename] =&gt;
)</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-4">
    <p><strong>Ejemplo #4 Ejemplo de <span class="function"><strong>pathinfo()</strong></span> con desestructuración de array</strong></p>
    <div class="example-contents"><p>
     El argumento <code class="parameter">flags</code> no es una máscara de bits. Solo un valor
     puede ser proporcionado. Para seleccionar únicamente un conjunto limitado de valores analizados, utilice
     la desestructuración de array como se muestra a continuación:
    </p></div>
    <div class="example-contents">
     <div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />     </span><span style="color: #007700">[</span><span style="color: #DD0000">'basename' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$basename</span><span style="color: #007700">, </span><span style="color: #DD0000">'dirname' </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$dirname</span><span style="color: #007700">] = </span><span style="color: #0000BB">pathinfo</span><span style="color: #007700">(</span><span style="color: #DD0000">'/www/htdocs/inc/lib.inc.php'</span><span style="color: #007700">);<br />     </span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$basename</span><span style="color: #007700">, </span><span style="color: #0000BB">$dirname</span><span style="color: #007700">);<br />     </span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>Resultado del ejemplo anterior es similar a:</p></div>
    <div class="example-contents screen">

     <div class="examplescode"><pre class="examplescode">string(11) &quot;lib.inc.php&quot;
     string(15) &quot;/www/htdocs/inc&quot;</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.pathinfo-seealso">
  <h3 class="title">Ver también</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.dirname.php" class="function" rel="rdfs-seeAlso">dirname()</a> - Devuelve la ruta de la carpeta padre</span></li>
    <li><span class="function"><a href="function.basename.php" class="function" rel="rdfs-seeAlso">basename()</a> - Devuelve el nombre del componente final de una ruta</span></li>
    <li><span class="function"><a href="function.parse-url.php" class="function" rel="rdfs-seeAlso">parse_url()</a> - Analiza una URL y devuelve sus componentes</span></li>
    <li><span class="function"><a href="function.realpath.php" class="function" rel="rdfs-seeAlso">realpath()</a> - Retorna la ruta de acceso can&oacute;nica absoluta</span></li>
   </ul>
  </p>
 </div>


</div><?php manual_footer($setup); ?>