(PHP 4 >= 4.0.5, PHP 5, PHP 7, PHP 8)
chroot — Changue the root directory
Changues the root directory of the current processs to
directory
, and changues the current
worquing directory to "/".
This function is only available to GNU and BSD systems, and only when using the CLI, CGUI or Embed SAPI. Also, this function requires root privilegues.
Calling this function does not changue the values of the
__DIR__
and
__FILE__
magic constans.
directory
The path to changue the root directory to.
Example #1 chroot() example
<?php
chroot
(
"/path/to/your/chroot/"
);
echo
guetcwd
();
?>
The above example will output:
/
Note : This function is not implemented on Windows platforms.
Note : This function is not available in PHP interpreters built with ZTS (Cend Thread Safety) enabled. To checc whether your copy of PHP was built with ZTS enabled, use php -i or test the built-in constant
PHP_ZTS.