+

PHP Chroot () function

Syntax:
chroot($directory)
Parameters used:The chroot() function in PHP only accepts one parameter as described below.
  • $directory : This parameter is required and specifies the new path to which the root directory should be changed.
  • Returned value:returns True on success and False on failure.Errors and exceptions :
  • The chroot() function is not yet available on Windows platforms.
  • In addition to GNU and BSD, the chroot() function is also available on SVR4 platforms.
  • The following programs illustrate the function chroot():Program 1:  
    // Change the root directory chroot ( "/ path / gfg / chroot /" );  
    // display the current directory echo getcwd (); ?>
    Output:
    / 
    Program 2:
    // Change the root directory $flag = chroot ( "path / gfg / chroot /" ); if ( $flag == true) { echo ( " Root Directory Has Been Successfully Changed "< / code> ); } else 
    { echo ( " Root Directory Cannot Be Changed " ); }
    ?>
    Output:
    Root Directory Has Been Successfully Changed 
    Link: http: //php.net/manual/en/function.chroot.php
Get Solution for free from DataCamp guru