In this article, you will learn how to change the root directory in PHP. The chroot() function in PHP changes the root directory of the current process to the directory, and changes the current working directory to “/”.
what is the syntax of the CHDIR() function in php?
chroot(directory)
Parameter | Description |
---|---|
directory | Required. Specifies the path to change the root directory to |
examples of the CHDIR() function
Example 1. In this example, we change the root directory.
<?php
// Change root directory
chroot("/path/to/chroot/");
// Get current directory
echo getcwd();
?>