PHP Tutorial - PHP chgrp() Function






Definition

The chgrp() function changes the usergroup of the specified file.

Syntax

PHP chgrp() Function has the following syntax.

chgrp(file,group)

Parameter

ParameterIs RequiredDescription
fileRequired.File to check
groupRequired.New group. Can be a group name or a group ID

Return

Returns TRUE on success and FALSE on failure.

Example


<?php//from ww  w .j  a  va  2  s  .c om
chgrp("test.txt","admin");

$filename = 'my_file.txt';

printf(filegroup($filename));
chgrp($filename, 8);
print "\n";
clearstatcache(); // do not cache filegroup() results
printf(filegroup($filename));
?>