PHP chdir() 函數

PHP Directory PHP Directory 參考手冊

實例

改變當前的目錄:

<?php
// Get current directory
echo getcwd() . "<br>";

// Change directory
chdir("images");

// Get current directory
echo getcwd();
?>

結果:

/home/php
/home/php/images


定義和用法

chdir() 函數改變當前的目錄。


語法

chdir(directory);

參數 描述
directory 必需。規定新的當前目錄。

技術細節

返回值: 成功則返回 TRUE。失敗則返回 FALSE,且拋出 E_WARNING 級別的錯誤。
PHP 版本: 4.0+


PHP Directory PHP Directory 參考手冊