chroot

(PHP 4 >= 4.0.5, PHP 5, PHP 7)

chrootChange the root directory

Descrierea

chroot ( string $directory ) : bool

Changes the root directory of the current process to directory, and changes the current working directory to "/".

This function is only available to GNU and BSD systems, and only when using the CLI, CGI or Embed SAPI. Also, this function requires root privileges.

Parametri

directory

The path to change the root directory to.

Valorile întoarse

Întoarce valoarea true în cazul succesului sau false în cazul eșecului.

Exemple

Example #1 chroot() example

<?php
chroot
("/path/to/your/chroot/");
echo 
getcwd();
?>

Exemplul de mai sus va afișa:

/

Note

Notă: Această funcție nu este implementată pe platformele Windows.

Notă: Această funcție nu este disponibilă în interpretatorii PHP cu ZTS (Zend Thread Safety) ativat. Pentru a verifica dacă copia dumneavoastră a PHP este cu ZTS activat utilizați php -i sau verificați constanta încorporată PHP_ZTS.

add a note add a note

User Contributed Notes 1 note

up
-28
drowningloli at gmail dot com
9 years ago
The chroot() function is also available on SVR4 platforms (not just GNU and BSD.)
To Top