Forum und email

chdir

(PHP 4, PHP 5)

chdir — Change directory

說明

bool chdir ( string $directory )

Changes PHP's current directory to directory .

參數

directory

The new current directory

Return值

如果成功則回傳 TRUE,失敗則回傳 FALSE

範例

Example#1 chdir() example

<?php

// current directory
echo getcwd() . "\n";

chdir('public_html');

// current directory
echo getcwd() . "\n";

?>

上例的輸出類似於:

/home/vincent
/home/vincent/public_html

註釋

Note: 安全模式被啟用時,PHP 將檢查被操作的目錄是否和正在執行的腳本有相同的 UID(擁有者)。

參見