Home >Backend Development >PHP Tutorial >Introduction to the use of php chroot() function?
php chroot() FunctionChange the root directory of the current process to directory, and change the current working directory to "/".
PS: This function requires root privileges and is only available on GNU and BSD systems when using CLI, CGI, and embedded SAPI. This function is not implemented on Windows platforms.
Syntax
chroot(directory);
Parameters: directory Required. Specifies the new root directory path.
This function returns TRUE if successful and FALSE if failed.
Instance of php chroot() function, use php chroot() function to change the root directory, the code is as follows:
<?php // Change root directory chroot("/path/to/chroot/"); // Get current directory echo getcwd(); ?>
Output result:
/
The above is the detailed content of Introduction to the use of php chroot() function?. For more information, please follow other related articles on the PHP Chinese website!