略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: chroot

2024-05-02

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 平台下实现。

add a noteadd a note

User Contributed Notes 1 note

up
-28
drowningloli at gmail dot com
7 years ago
The chroot() function is also available on SVR4 platforms (not just GNU and BSD.)

官方地址:https://www.php.net/manual/en/function.chroot.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3