How to use Directory chroot in PHP

In this article I am going to explain about chroot function in PHP.
  • 1557

PHP chroot() function

The directory chroot function changes the root directory to a specified directory. It returns true on success otherwise returns false.

Syntax of  chroot function

chroot(directory)

Parameters in chroot function

It has only one parameter:

Parameter Description
directory It defines a new root directory.

Example of directory chroot  function

<html>

<body>

 

<?php

if(function_exists('chroot'))

{

chroot("/path/to/your/chroot/");

echo getcwd();

}

else

{

   echo 'does not exist';

echo "<br />";

   echo 'This function does not support window platform';

}

?>

 

</body>

</html>

 

Output:

chroot function.jpg

You may also want to read these related articles :
here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.