<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.dir.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.chdir.php',
    1 => 'chdir',
    2 => 'Change de dossier',
  ),
  'up' => 
  array (
    0 => 'ref.dir.php',
    1 => 'Fonctions sur les dossiers',
  ),
  'prev' => 
  array (
    0 => 'ref.dir.php',
    1 => 'Fonctions sur les dossiers',
  ),
  'next' => 
  array (
    0 => 'function.chroot.php',
    1 => 'chroot',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/dir/functions/chdir.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.chdir" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">chdir</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">chdir</span> &mdash; <span class="dc-title">Change de dossier</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.chdir-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>chdir</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$directory</code></span>): <span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>chdir()</strong></span> change le dossier courant de PHP en
   <code class="parameter">directory</code>.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chdir-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       Le nouveau répertoire courant
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chdir-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Cette fonction retourne <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> en cas de succès ou <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> si une erreur survient.
  </p> 
 </div>


 <div class="refsect1 errors" id="refsect1-function.chdir-errors">
  <h3 class="title">Erreurs / Exceptions</h3>
  <p class="para">
   Émet une erreur de niveau <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
   si une erreur survient.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.chdir-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>chdir()</strong></span></strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">// dossier courant<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">getcwd</span><span style="color: #007700">() . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">chdir</span><span style="color: #007700">(</span><span style="color: #DD0000">'public_html'</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">// dossier courant<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">getcwd</span><span style="color: #007700">() . </span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br /><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">/home/vincent
/home/vincent/public_html</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.chdir-notes">
  <h3 class="title">Notes</h3>
  <div class="caution"><strong class="caution">Attention</strong>
   <p class="para">
    Si l&#039;interpréteur PHP a été compilé avec ZTS d&#039;activé (Zend Thread Safety),
    tous les changements du dossier courant réalisés via la fonction
    <span class="function"><strong>chdir()</strong></span> seront invisibles du système d&#039;exploitation.
    Toutes les fonctions internes de PHP continueront à respecter le changement
    de dossier courant ; mais tous les appels aux fonctions des bibliothèques
    externes via <a href="book.ffi.php" class="link">FFI</a> ne le respecteront pas.
    Il est possible de vérifier si la copie de PHP a été compilée avec l&#039;activation
    de ZTS en utilisant <strong class="command">php -i</strong> ou en utilisant la constante
    interne <strong><code><a href="reserved.constants.php#constant.php-zts">PHP_ZTS</a></code></strong>.
   </p>
  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.chdir-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.getcwd.php" class="function" rel="rdfs-seeAlso">getcwd()</a> - Retourne le dossier de travail courant</span></li>
   </ul>
  </p>
 </div>

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