<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.chdir.php',
    1 => 'chdir',
    2 => 'ディレクトリを変更する',
  ),
  'up' => 
  array (
    0 => 'ref.dir.php',
    1 => 'ディレクトリ 関数',
  ),
  'prev' => 
  array (
    0 => 'ref.dir.php',
    1 => 'ディレクトリ 関数',
  ),
  'next' => 
  array (
    0 => 'function.chroot.php',
    1 => 'chroot',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    '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">ディレクトリを変更する</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.chdir-description">
  <h3 class="title">説明</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">
   PHP のカレントディレクトリを <code class="parameter">directory</code>
   に変更します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.chdir-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">directory</code></dt>
     <dd>
      <p class="para">
       新しいカレントディレクトリ
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.chdir-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   成功した場合に <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong> を、失敗した場合に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返します。
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.chdir-errors">
  <h3 class="title">エラー / 例外</h3>
  <p class="para">
   失敗した場合は <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> レベルのエラーが発生します。
  </p>
 </div>

 
 <div class="refsect1 examples" id="refsect1-function.chdir-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <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">// カレントディレクトリ<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">// カレントディレクトリ<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>上の例の出力は、
たとえば以下のようになります。</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">注意</h3>
  <div class="caution"><strong class="caution">警告</strong>
   <p class="para">
    PHP インタプリタが ZTS (Zend Thread Safety) を有効にしてビルドされている場合、
    <span class="function"><strong>chdir()</strong></span> 関数を使って行った現在のディレクトリの変更はオペレーティングシステムには見えません。
    全てのPHPのビルトイン関数は、現在のディレクトリの変更を尊重しますが、
    <a href="book.ffi.php" class="link">FFI</a> を使って呼び出された外部ライブラリはそうではありません。
    あなたの PHP で ZTS が有効かどうかを調べるには、<strong class="command">php -i</strong> コマンドを使うか、
    ビルトイン定数<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">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.getcwd.php" class="function" rel="rdfs-seeAlso">getcwd()</a> - カレントのワーキングディレクトリを取得する</span></li>
   </ul>
  </p>
 </div>

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