PHP chroot() Function

PHP chdir() Function
PHP trigger_error() Function

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)
ParameterDescription
directoryRequired. Specifies the path to change the root directory to
PHP chdir() method

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();
?>
PHP chdir() Function
PHP trigger_error() Function
en English
X
Scroll to Top