完整的 PHP Filesystem 参考手册
定义和用法
chmod() 函数改变指定文件的权限。
如果成功则返回 TRUE,如果失败则返回 FALSE。
语法
chmod(file,mode)
参数 | 描述 |
---|---|
file | 必需。规定要检查的文件。 |
mode | 必需。规定新的权限。 mode 参数由 4 个数字组成:
可能的值(如需设置多个权限,请对下面的数字进行总计):
|
实例
<?php
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);
// Read and write for owner, read for everybody else
chmod("test.txt",0644);
// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);
// Everything for owner, read for owner's group
chmod("test.txt",0740);
?>
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);
// Read and write for owner, read for everybody else
chmod("test.txt",0644);
// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);
// Everything for owner, read for owner's group
chmod("test.txt",0740);
?>
完整的 PHP Filesystem 参考手册其他扩展