• 首页
  • vue
  • TypeScript
  • JavaScript
  • scss
  • css3
  • html5
  • php
  • MySQL
  • redis
  • jQuery
  • chroot()

    (PHP 4 >= 4.0.5, PHP 5, PHP 7)

    改变根目录

    说明

    chroot(string $directory): bool

    将当前进程的根目录改变为$directory

    本函数仅在系统支持且运行于 CLI,CGI 或嵌入 SAPI 版本时才能正确工作。此外本函数还需要 root 权限。

    参数

    $directory

    新目录

    返回值

    成功时返回TRUE,或者在失败时返回FALSE

    范例

    Example #1chroot()example

    <?php
    chroot("/path/to/your/chroot/");
    echo getcwd();
    ?>
    

    以上例程会输出:

    /
    

    注释

    Note:此函数未在 Windows 平台下实现。

    The chroot() function is also available on SVR4 platforms (not just GNU and BSD.)

    上篇:chdir()

    下篇:closedir()