PHP chroot() 函数
PHP chroot() 函数 实例 改变根目录: <?php // 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 chroot() 函数
实例
改变根目录:
<?php // 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+ |
交流与评论