Php/func directory chroot

来自菜鸟教程
跳转至:导航、​搜索

PHP chroot()函数

Directory PHP目录参考

更改根目录:

<?php
// Change root directory

 chroot("/path/to/chroot/");

// Get current directory

 echo getcwd();
?>

结果:

 /



定义和用法

chroot()函数将当前进程的根目录更改为 directory ,并将当前工作目录更改为“ /”。

注意: 该功能需要root特权,并且仅适用于GNU和BSD系统,并且仅在使用CLI,CGI或Embed SAPI时可用。

注意: Windows平台上未实现此功能。

句法

chroot(directory)

参数值

参数 描述
directory 需要。指定将根目录更改为的路径

技术细节

返回值: 成功则为真。失败时为FALSE。
PHP版本: 4.0.5+

Directory PHP目录参考