chgrp()function in PHP


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 24-Jun-2020

178 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements