chgrp()function in PHP

PHPProgrammingServer Side Programming

The chgroup() function updates the file group. Remember that only the superuser has the authority to change the group of a file arbitrarily,

Syntax

chgroup($file_path, group)

Parameters

  • file_path − Set the path of file or directory to be checked. Required.

  • group − Set the new user group name or number.

Return

The chgroup() function returns.

  • True, on success,
  • False, on failure

Example

The following is an example that checks for file “one.txt” and changes its file group.

<?php
   $file_path1 = "/themes/myfiles/one.php";
   $file_path2 = "/themes/myfiles/two.php";
   // changing groups of two files
   chgrp($file_path1, "admin");
   chgrp($file_path2, "guest");
?>

Output

TRUE
TRUE
raja
Published on 03-Oct-2018 08:20:06
Advertisements