Curriculum
Course: PHP Basic
Login

Curriculum

PHP Basic

PHP Install

0/1

PHP Casting

0/1

PHP Constants

0/1

PHP Magic Constants

0/1

PHP Operators

0/1

PHP Reference

0/276
Text lesson

chroot()

Example

Change the root directory for the current process.

<?php
// Change root directory
chroot(“/path/to/chroot/”);

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

Result:

/

Definition and Usage

The chroot() function changes the root directory of the current process to the specified directory and sets the current working directory to “/”.

Note: This function requires root privileges and is available only on GNU and BSD systems, and only when using CLI, CGI, or Embed SAPI.

Note: This function is not implemented on Windows platforms.

Syntax

chroot(directory)

Parameter Values

 

Parameter

Description

directory

Required. Specifies the path to change the root directory to

Technical Details

Return Value:

Returns TRUE on success and FALSE on failure.

PHP Version:

4.0.5+