chgrp in PHP

Syntax of chgrp in PHP

bool chgrp(string path, mixed group)

Changes the group for the file path to group; PHP must have appropriate privileges for this function to work. Returns true if the change was successful and false if not.

<?php
$filename = 'shared_file.txt';
$format = "%s's Group ID @ %s: %d\n";
printf($format, $filename, date('r'), filegroup($filename));
chgrp($filename, 8);
clearstatcache(); // do not cache filegroup() results
printf($format, $filename, date('r'), filegroup($filename));
?>

Leave a Comment