PHP chroot() 函數
實例
改變根目錄:
<?php
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
結果:
/
定義和用法
chroot() 函數改變當前進程的根目錄為 directory,並把當前工作目錄改為 "/"。
注意:該函數需要 root 許可權,且僅在 GNU 和 BSD 系統上僅當使用 CLI、CGI、嵌入式 SAPI 時可用。該函數沒有在 Windows 平臺上實現。
語法
chroot(directory);
參數 | 描述 |
---|---|
directory | 必需。規定新的根目錄路徑。 |
技術細節
返回值: | 成功則返回 TRUE,失敗則返回 FALSE。 |
---|---|
PHP 版本: | 4.0.5+ |
