chroot
(PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8)
chroot — 改变根目录
说明
chroot(string
$directory
): bool
将当前进程的根目录改变为
directory
。
本函数仅在系统支持且运行于 CLI,CGI 或嵌入 SAPI 版本时才能正确工作。此外本函数还需要 root 权限。
参数
-
directory
-
新目录
返回值
成功时返回 true
, 或者在失败时返回 false
。
范例
示例 #1 chroot() example
<?php
chroot("/path/to/your/chroot/");
echo getcwd();
?>
以上例程会输出:
/
注释
注意: 此函数未在 Windows 平台下实现。

User Contributed Notes 1 note
drowningloli at gmail dot com ¶
7 years ago
The chroot() function is also available on SVR4 platforms (not just GNU and BSD.)