PHP chroot() Function
Definition
The chroot() function changes the root directory of the current process to directory, and changes the current working directory to "/".
Syntax
PHP chroot() Function has the following syntax.
chroot(directory);
Parameter
Parameter | Is Required | Description |
---|---|---|
directory | Required. | Path to change the root directory to |
Return
PHP chroot() Function returns TRUE on success. FALSE on failure.
Note
This function requires root privileges, and is only available to GNU and BSD systems.
Example
Change the root directory:
<?php//from ww w .j av a 2 s .c o m
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>