The chgrp() function in PHP is an inbuilt function which is used to change the user group of the specified file. It returns true on success and false on failure. Only the superuser has the right to change the group of a file arbitrarily.
bool chgrp ( $filename, $group )
Parameters: The chown() function in PHP accepts two parameters which are filename and user.
- $filename: It specifies the file whose user group you want to change.
- $group: It specifies the new user group. It can be a group name or a number.
Return Value: The chgrp() function returns true on success and false on failure.
Errors And Exception:
- The chgrp() function in PHP doesn’t works for remote files.It only works on files which are accessible by the server’s filesystem.
- 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.
Input : chgrp("gfg.txt", "administrator") Output :true Input : $filename = "/user/Desktop/geeksforgeeks/gfg.txt"; chgrp( $filename, "guest" ); Output :true
Below programs illustrate the chgrp() function:
- How to get the function name inside a function in PHP ?
- p5.js | min() function
- p5.js | cos() function
- p5.js | red() function
- PHP | dir() Function
- PHP | pi( ) Function
- D3.js | d3.set.add() Function
- D3.js | d3.map.has() Function
- p5.js | log() function
- p5.js | sin() function
- p5.js | tan() function
- D3.js | d3.set.has() Function
- D3.js | d3.rgb() Function
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.