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.
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:
Root Directory Has Been Successfully Changed
Reference : http://php.net/manual/en/function.chroot.php
- How to get the function name inside a function in PHP ?
- D3.js | d3.set.has() Function
- PHP | next() Function
- D3.js | d3.hcl() Function
- PHP | tan( ) Function
- PHP | exp() Function
- p5.js | str() function
- p5.js | int() function
- D3.js | d3.rgb() Function
- D3.js | d3.mean() function
- p5.js | nfs() Function
- D3.js | d3.sum() function
- PHP | pow( ) Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.