Current Location: Home> Function Categories> lchgrp

lchgrp

Modify all groups of symbolic links
Name:lchgrp
Category:File system
Programming Language:php
One-line Description:Modify the group of files or directories, similar to the chgrp() function

Function name: lchgrp()

Function description: The lchgrp() function is used to modify the group to which a file or directory belongs, similar to the chgrp() function. The difference is that the lchgrp() function can operate on a symbolic link, while the chgrp() function can only operate on the target pointed to by the symbolic link.

Applicable version: The lchgrp() function is available in PHP 4.0.5 and later.

Syntax: bool lchgrp ( string $filename , mixed $group )

parameter:

  • $filename: The path to the file or directory of the group to which you want to modify.
  • $group: The name or group ID of the new group to which it belongs. Can be a string or an integer.

Return value: Return true on success, and false on failure.

Example 1: Modify the file's group to "admin".

 $filename = '/path/to/file.txt'; $group = 'admin'; if (lchgrp($filename, $group)) { echo "所属组修改成功!"; } else { echo "所属组修改失败!"; }

Example 2: Modify the group to which the directory belongs to a group with a group ID of 1000.

 $dirname = '/path/to/directory'; $group = 1000; if (lchgrp($dirname, $group)) { echo "所属组修改成功!"; } else { echo "所属组修改失败!"; }

Notes:

  • Executing the lchgrp() function requires sufficient file system permissions.
  • If the file or directory does not exist, or the file or directory cannot be accessed, the lchgrp() function will return false.
  • On Windows operating systems, the lchgrp() function is not available.
Similar Functions
  • Returns the file name part in the path basename

    basename

    Returnsthefilenamepa
  • Rename a file or directory rename

    rename

    Renameafileordirecto
  • alias for disk_free_space diskfreespace

    diskfreespace

    aliasfordisk_free_sp
  • Match file names with pattern fnmatch

    fnmatch

    Matchfilenameswithpa
  • Test whether the file pointer reaches the end of the file feof

    feof

    Testwhetherthefilepo
  • Create a file with a unique file name tempnam

    tempnam

    Createafilewithauniq
  • Output file readfile

    readfile

    Outputfile
  • Open process file pointer popen

    popen

    Openprocessfilepoint
Popular Articles