PHP chroot()函数与示例
PHPchroot()方法
chroot的完整格式为“ChangeRoot”,函数chroot()“用于更改根目录,并且还将当前工作目录更改为”/“。
语法:
chroot(directory);
参数:
directory–它定义了新的根目录。
返回值:
如果根目录成功更改,则返回布尔值“TRUE”;如果根目录未更改,则返回“FALSE”。
注意:
chroot()在WindowsPHP安装中不起作用。根据参考手册,仅当在CLI/CGI/EmbeddedSAPI中使用时,该功能仅在PHP上可用。
chroot()函数需要根特权。请参考官方php.net手动尝试此功能之前,PHPchroot()函数
对于此功能可能造成的任何损害,我们概不负责。
以下是程序的示例输出,
When Success:
/
root directory is changed...
/home/folder1
When fail:
/
root directory is not changed...示例:更改root导演的PHP代码
<?php
echo getcwd();
//建立目录
mkdir("/home/folder1");
//更改根目录
$ret_value = chroot("/home/folder1");
if($ret_value == true)
echo "root directory is changed...";
else
echo "root directory is not changed...";
//获取当前目录
echo getcwd();
?>输出结果
root directory is changed... /home/folder1
参考:PHPchroot()函数
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短