Home  >  Article  >  Backend Development  >  Introduction to the use of php chroot() function?

Introduction to the use of php chroot() function?

怪我咯
怪我咯Original
2017-07-11 09:17:111472browse

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn