例1,修改文件的属主与属组,学习函数chown、chgrp的用法。
<?php
chown('/tmp/myfile.txt','sklar'); // specify user by name
chgrp('/home/sklar/schedule.txt','soccer'); // specify group by name
chown('/tmp/myfile.txt',5001); // specify user by uid
chgrp('/home/sklar/schedule.txt',102); // specify group by gid
?>
例2,chown() and chgrp()函数实例
<?php
$dr = @opendir("/tmp/");
if(!$dr) {
echo "Error, couldn't open /tmp/!";
exit;
}
while(($filename = readdir($dr)) !== false) {
chown($filename, "php");
chgrp($filename, "phpgroup");
}
closedir($dr);
?>