PHP chroot() Function

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

ParameterIs RequiredDescription
directoryRequired.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//from ww w  .j av  a  2 s  .c  o m
// Change root directory
chroot("/path/to/chroot/");

// Get current directory
echo getcwd();
?>




















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions