chgrp

Changes file group

Syntax

chgrp ( string $filename , mixed $group ) : bool

Parameters

filename

Path to the file.

group

A group name or number.

Return

Returns TRUE on success or FALSE on failure.

Examples

<?

$format = "filename: %s\ndate: %s\ngroup: %d\n";
$filename = 'file.txt';

printf($format, $filename, date('r'), filegroup($filename));

$group = 8;
chgrp($filename, $group);
clearstatcache(); // do not cache filegroup() results

printf($format, $filename, date('r'), filegroup($filename));

?>
filename: file.txt
date: Mon, 06 Dec 2021 18:32:20 +0000
group: 0
filename: file.txt
date: Mon, 06 Dec 2021 18:32:20 +0000
group: 8

PHP

Home Menu