PHP chgrp() Function

PHP chgrp Function


Definition:

In PHP  chgrp() function  is inbuilt function.The chgrp() function changes the usergroup of the specified file.

Syntax

   chgrp(filegroup)

Parameter 
Parameter Description
file Required. Specifies the path to the file to change user group for
group Required. Specifies the new group name or number

Errors And Exception:

  1. The chgrp() function in PHP doesn’t works for remote files.It only works on files which are accessible by the server’s filesystem.
  2. PHP checks whether the files or directories which are being operated have the same owner as the script that is being executed or not when safe mode is enabled.
Example

 Change the usergroup to "administrator" for the "test.txt" file:

<?php
    chgrp("test.txt","administrator")
 ?>