PHP Chgrp () Function

bool chgrp ($filename, $group)
Parameters:PHP chown() function takes two parameters: filename and user.
  • $filename : Specifies the file whose user group you want to change.
  • $group : Indicates a new user group. This can be a group name or a number.
  • Returned value:chgrp() function returns true on success and false on error.Errors and Exceptions :
  • The chgrp() function in PHP does not work for remote files. It only works on files that are accessible to the server`s file system.
  • PHP checks if the files or directories you are working with have the same owner as the script being executed or not when safe mode is enabled.
  • Examples :
    Input: chgrp ("gfg.txt", "administrator") Output: true Input: $filename = " /user/Desktop/engineerforengineer/gfg.txt "; chgrp ($filename, "guest"); Output: true
    The programs below illustrate the chgrp() function:Program 1 :  
    // changes the file group to admin chgrp ( "gfg.txt" , "administrator" ) 
    true  Program 2 :       
    // Changes the filegroup to guest $filename = "/ user / Desktop / engineerforengineer / gfg.txt" ; chgrp ( $filename , " guest " ); chown ( $path , $user_name );  
    true  Link:
    http://php.net/manual/ en / function.chgrp.php
    Get Solution for free from DataCamp guru