array ( 0 => 'index.php', 1 => 'PHP Manual', ), 'head' => array ( 0 => 'UTF-8', 1 => 'ja', ), 'this' => array ( 0 => 'function.chdir.php', 1 => 'chdir', ), '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', ), ); $setup["toc"] = $TOC; $setup["toc_deprecated"] = $TOC_DEPRECATED; $setup["parents"] = $PARENTS; manual_setup($setup); ?>
(PHP 4, PHP 5, PHP 7, PHP 8)
chdir — ディレクトリを変更する
directory
新しいカレントディレクトリ
失敗した場合は E_WARNING
レベルのエラーが発生します。
例1 chdir() の例
<?php
// カレントディレクトリ
echo getcwd() . "\n";
chdir('public_html');
// カレントディレクトリ
echo getcwd() . "\n";
?>
上の例の出力は、 たとえば以下のようになります。
/home/vincent /home/vincent/public_html