PHP chroot () function
Examples
Change the root directory:
<?php
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
result:
/
Definition and Usage
chroot () function to change the root directory of the current process to directory, and the current working directory to "/."
Note: This function requires root privileges, and only on GNU and BSD systems only when using the CLI, CGI, an embedded SAPI available. This function is not implemented on Windows platforms.
grammar
chroot( directory );
参数 | 描述 |
---|---|
directory | 必需。规定新的根目录路径。 |
technical details
return value: | Success, returns TRUE, on failure returns FALSE. |
---|---|
PHP version: | 4.0.5+ |
PHP Directory Reference