chgrp()
chgrp() — Changes file group.
Built-in function of PHP 8.5. The manual lists it as available in PHP 4, PHP 5, PHP 7, PHP 8. This page is the reference card: signature, parameters and return value, plus the changelog and the example the manual provides.
What it does
Attempts to change the group of the file filename to group.
Signature
chgrp(string $filename, string|int $group): bool
Parameters
| Parameter | Type | What it takes |
|---|---|---|
| $filename | string | Path to the file. |
| $group | string|int | A group name or number. |
Return value
Returns true on success or false on failure.
Example
A runnable snippet:
$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));
See also
All PHP 8.5 built-in functions
Reference card built from the PHP manual page chgrp() (PHP documentation, CC BY 3.0). The page is generated from the manual, so the wording of the parameter and return value text follows php.net.