php chmod 函数 改变文件模式
在我们操作文件时经常会经用chmod函数来改变指定目录的操作权限哦,
属性
( PHP 4中, PHP 5中)
搭配chmod -改变文件模式
描述
布尔属性(字符串$文件名,国际$模式)
企图改变模式指定的文件,以所提供的模式。
参数
文件名
文件路径。
模式
请注意,模式是不会自动假定为八进制值,所以字符串(如“克+瓦特” )将无法正常工作。为了确保预期的操作,你需要前缀模式下零( 0 ) :
<?php chmod("/somedir/somefile", 755); // decimal; probably incorrect chmod("/somedir/somefile", "u+rwx,go+rx"); // string; incorrect chmod("/somedir/somefile", 0755); // octal; correct value of mode ?>
该模式参数包含三个八进制数组成部分指定准入限制的所有者,用户组中的主人是在和其他人一样在这一秩序。一个组成部分可以计算,增加了必要的权限,这个目标用户群。编号1意味着您授予执行权, 2号意味着你的档案写入, 4号意味着你的档案可读性。购买了这些数字来指定需要的权利。您也可以阅读更多关于模式与Unix系统'男子1属性'和'人2属性。
<?php // Read and write for owner, nothing for everybody else chmod("/somedir/somefile", 0600); // Read and write for owner, read for everybody else chmod("/somedir/somefile", 0644); // Everything for owner, read and execute for others chmod("/somedir/somefile", 0755); // Everything for owner, read and execute for owner's group chmod("/somedir/somefile", 0750); ?>
文章网址:http://www.phprm.com/function/ad7d09f46fce96a82f06fe711adeb47b.html
随意转载^^但请附上教程地址。