PHP chroot() Function
In this chapter you will learn:
- Definition for PHP chroot() Function
- Syntax for PHP chroot() Function
- Parameter for PHP chroot() Function
- Return for PHP chroot() Function
- Note for PHP chroot() Function
- Example - Change the root directory
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//j av a 2s . c o m
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>
Next chapter...
What you will learn in the next chapter:
- Definition for PHP clearstatcache() Function
- Syntax for PHP clearstatcache() Function
- Note for PHP clearstatcache() Function
- Example - clears the file status cache
Home » PHP Tutorial » PHP File Functions