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+ |
PHP Directory參考手冊