If you call chgrp and pass a non-existent group, you'll get the warning "Warning: chgrp(): Unable to find gid for nogroup in".
To check beforehand if the group exists, use posix_getgrid() or posix_getgrnam().
chgrp
(PHP 4, PHP 5)
chgrp — ファイルのグループを変更する
説明
(名前または番号で指定した)ファイル filename のグループを group に変更しようと試みます。
スーパーユーザのみがファイルのグループを任意に変更できます。 その他のユーザは、ファイルのグループをそのユーザがメンバーとして 属しているグループに変更できます。
パラメータ
- filename
-
ファイルへのパス。
- group
-
グループ名あるいはグループ番号。
返り値
成功した場合に TRUE を、失敗した場合に FALSE を返します。
例
例1 ファイルのグループの変更
<?php
$filename = 'shared_file.txt';
$format = "%s's Group ID @ %s: %d\n";
printf($format, $filename, date('r'), filegroup($filename));
chgrp($filename, 8);
printf($format, $filename, date('r'), filegroup($filename));
?>
chgrp
Dan Dascalescu
04-Dec-2007 01:12
04-Dec-2007 01:12
