Home  >  Article  >  Backend Development  >  The role of the chgrp() function in PHP is to change the user group to which a file or directory belongs.

The role of the chgrp() function in PHP is to change the user group to which a file or directory belongs.

WBOY
WBOYforward
2023-09-12 15:45:08794browse

The role of the chgrp() function in PHP is to change the user group to which a file or directory belongs.

chgroup() function updates the file group. Remember, only superuser has permission to arbitrarily change the file's group,

Syntax

chgroup($file_path, group)

Parameters

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

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

Return

chgroup() function returns.

  • Return True on success, False on failure
  • Example

    The following example checks the file "one.txt" and changes its filegroup.

    <?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

The above is the detailed content of The role of the chgrp() function in PHP is to change the user group to which a file or directory belongs.. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:tutorialspoint.com. If there is any infringement, please contact admin@php.cn delete