<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.pathinfo.php',
    1 => 'pathinfo',
    2 => 'Retourne des informations sur un chemin syst&egrave;me',
  ),
  'up' => 
  array (
    0 => 'ref.filesystem.php',
    1 => 'Fonctions sur les syst&egrave;mes de fichiers',
  ),
  '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' => 'fr',
    '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">Retourne des informations sur un chemin système</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.pathinfo-description">
  <h3 class="title">Description</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> retourne des informations sur le chemin
   <code class="parameter">path</code>, sous forme de chaîne ou de tableau associatif, ceci
   dépend du paramètre <code class="parameter">flags</code>.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Pour plus d&#039;informations sur la lecture du chemin courant,
    se référer à la section sur les
    <a href="language.variables.predefined.php" class="link">variables prédéfinies</a>.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    <span class="function"><strong>pathinfo()</strong></span> opère naïvement sur la chaîne d&#039;entrée,
    et n&#039;est pas consciente du système de fichiers actuel, ou des composants
    de chemins tels que &quot;<code class="literal">..</code>&quot;.
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Sur les systèmes Windows uniquement, le caractère <code class="literal">\</code> sera
    interprété comme un séparateur de répertoire. Sur les autres systèmes, il sera
    traité comme n&#039;importe quel autre caractère.
   </p>
  </p></blockquote>
  <div class="caution"><strong class="caution">Attention</strong>
   <p class="para">
    La fonction <span class="function"><strong>pathinfo()</strong></span> est sensible à la configuration locale,
    aussi, pour qu&#039;elle analyse correctement un chemin contenant les
    caractères sur plusieurs octets, la locale correspondante doit être définie
    en utilisant la fonction <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">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">path</code></dt>
     <dd>
      <p class="para">
       Le chemin à analyser.
      </p>
     </dd>
    
    
     <dt><code class="parameter">flags</code></dt>
     <dd>
      <p class="para">
       Spécifie quel élément sera retourné. Il est possible de passer l&#039;une des 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> et
       <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> n&#039;est pas renseigné,
       tous les éléments sont retournés.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.pathinfo-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Si <code class="parameter">flags</code> n&#039;est pas utilisé, cette fonction retourne
   un tableau associatif contenant les éléments suivants :
   <code class="literal">dirname</code>, <code class="literal">basename</code>,
   <code class="literal">extension</code> (s&#039;il y en a), et <code class="literal">filename</code>.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Si <code class="parameter">path</code> contient plus d&#039;une extension,
    <strong><code><a href="filesystem.constants.php#constant.pathinfo-extension">PATHINFO_EXTENSION</a></code></strong> retourne uniquement le
    dernier et <strong><code><a href="filesystem.constants.php#constant.pathinfo-filename">PATHINFO_FILENAME</a></code></strong> va supprimer
    uniquement le dernier également (voir le premier exemple ci-dessous).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
  <p class="para">
    Si <code class="parameter">path</code> n&#039;a pas d&#039;extension, l&#039;élément
    <code class="literal">extension</code> ne sera pas retourné
    (voir le second exemple ci-après).
   </p>
  </p></blockquote>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Si <code class="literal">basename</code> du paramètre <code class="parameter">path</code>
    commence par un point, les caractères suivants sont interprétés comme l&#039;
    <code class="literal">extension</code>, et le <code class="literal">filename</code> sera vide
    (voir le troisième exemple ci-dessous).
   </p>
  </p></blockquote>
  <p class="para">
   Si <code class="parameter">flags</code> est utilisé, cette fonction retourne
   une <a href="language.types.string.php" class="link">chaîne de caractères</a> contenant les éléments.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.pathinfo-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <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>L&#039;exemple ci-dessus va afficher :</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>Exemple #2 Exemple <span class="function"><strong>pathinfo()</strong></span> sans extension</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>Résultat de l&#039;exemple ci-dessus est similaire à :</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>Exemple #3 Exemple avec <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>Résultat de l&#039;exemple ci-dessus est similaire à :</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>Exemple #4 Exemple de <span class="function"><strong>pathinfo()</strong></span> avec déréférencement de tableau</strong></p>
    <div class="example-contents"><p>
     Le paramètre <code class="parameter">flags</code> n&#039;est pas un masque de bits. Seule une valeur
     peut être fournie. Pour sélectionner uniquement un ensemble limité de valeurs analysées, il convient d&#039;utiliser
     la déstructuration de tableau comme ceci :
    </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>Résultat de l&#039;exemple ci-dessus est similaire à :</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">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.dirname.php" class="function" rel="rdfs-seeAlso">dirname()</a> - Renvoie le chemin du dossier parent</span></li>
    <li><span class="function"><a href="function.basename.php" class="function" rel="rdfs-seeAlso">basename()</a> - Retourne le nom de la composante finale d'un chemin</span></li>
    <li><span class="function"><a href="function.parse-url.php" class="function" rel="rdfs-seeAlso">parse_url()</a> - Analyse une URL et retourne ses composants</span></li>
    <li><span class="function"><a href="function.realpath.php" class="function" rel="rdfs-seeAlso">realpath()</a> - Retourne le chemin canonique absolu</span></li>
   </ul>
  </p>
 </div>


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