PHP | chroot( ) Function Last Updated : 11 Jul, 2018 Summarize Comments Improve Suggest changes Share Like Article Like Report The chroot() function in PHP is an inbuilt function which is used to change the root directory of the current process to directory. The chroot() function changes the current working directory to "/". The chroot() function is only available to GNU and BSD systems, and only when the user is using the CLI, CGI or Embed SAPI. Apart from this the chroot() function also requires root privileges for functioning. Syntax: chroot($directory) Parameters Used: The chroot() function in PHP accepts only one parameter as described below. $directory: It is a mandatory parameter which specifies the new path to which the root directory has to be changed. Return Value: It returns True on success and False on failure. Errors And Exceptions: The chroot() function is not available on windows platforms yet. Apart from GNU and BSD, the chroot() function is also available on SVR4 platforms. Below programs illustrate the chroot() function: Program 1: php <?php // Changing root directory chroot("/path/gfg/chroot/"); // displaying current directory echo getcwd(); ?> Output: / Program 2: php <?php // Changing root directory $flag = chroot("path/gfg/chroot/"); if($flag == true) { echo("Root Directory Has Been Successfully Changed"); } else { echo("Root Directory Cannot Be Changed"); } ?> Output: Root Directory Has Been Successfully Changed Reference : http://php.net/manual/en/function.chroot.php Comment More infoAdvertise with us Next Article PHP | dir() Function S Shubrodeep Banerjee Follow Improve Article Tags : Misc Web Technologies PHP PHP-file-handling Practice Tags : Misc Similar Reads PHP chdir() Function PHP chdir() function is used to change the current directory to new directory path. It takes only a single argument as new directory path. Syntaxbool chdir(string $new_directory_path)ParametersThis function accepts one parameter, which is mandatory. Return ValueIt returns a boolean operator as retur 2 min read PHP | ftp_chdir() function The ftp_chdir() function is an inbuilt function in PHP which is used to change the current directory on the FTP server. Syntax: ftp_chdir( $ftp_connection, $directory ) Parameter: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required paramete 2 min read PHP | dir() Function The dir() function in PHP is an inbuilt function which is used to return an instance of the Directory class. The dir() function is used to read a directory, which includes the following: The given directory is opened. The two properties handle and path of dir() are available. Both handle and path pr 2 min read PHP | ftell( ) Function The ftell() function in PHP is an inbuilt function which is used to return the current position in an open file. The file is sent as a parameter to the ftell() function and it returns the current file pointer position on success, or FALSE on failure.Syntax:  ftell( $file ) Parameters Used: The ftel 2 min read PHP | fstat( ) Function The fstat() function in PHP is an inbuilt function which is used to return information about an open file. The file name is sent as a parameter to the fstat() function and it returns an array with the following elements : Numeric Associative Description 0 dev Device number 1 ino inode number* 2 mode 3 min read PHP | ftp_exec() function The ftp_exec() function is an inbuilt function in PHP that is used to execute a command on the FTP server. Syntax: ftp_exec( $ftp_connection, $command ) Parameters: This function accepts two parameters as mentioned above and described below:  $ftp_connection: It is required parameter. It specifies 2 min read Like