PHP chroot()Functions
PHP Directory Reference Manual
Examples
Change 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
The chroot() function changes the root directory of the current process todirectory, and changes the current working directory to "/".
Note:This function requires root privileges and is only available on GNU and BSD systems when using CLI, CGI, or embedded SAPI. This function is not implemented on the Windows platform.
Syntax
chroot(directory);
| Parameters | Description |
|---|---|
| directory | Required. Specifies the new root directory path. |
Technical Details
| Return value: | Returns TRUE on success, FALSE on failure. |
|---|---|
| PHP Version: | 4.0.5+ |
PHP Directory Reference Manual Other Extensions