Change the root directory:
<?php
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
Result:
/
The chroot() function changes the root directory of the current process to directory, and changes the current working directory to "/".
Note: This function requires root privileges, and is only available to GNU and BSD systems, and only when using the CLI, CGI or Embed SAPI.
Note: This function is not implemented on Windows platforms.
chroot(
directory)
Parameter | Description |
---|---|
directory | Required. Specifies the path to change the root directory to |
Return Value: | TRUE on success. FALSE on failure. |
---|---|
PHP Version: | 4.0.5+ |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!