lchown
Modify the owner of the symbolic link
Function name: lchown()
Applicable version: PHP 4, PHP 5, PHP 7
Function description: The lchown() function is used to change the owner of the specified file. Unlike the chown() function, the lchown() function can handle symbolic link files.
Syntax: bool lchown ( string $filename , mixed $user )
parameter:
Return value:
Example:
// 示例一:将文件的所有者更改为新用户$filename = '/path/to/file.txt'; $user = 'newuser'; if (lchown($filename, $user)) { echo "文件所有者已成功更改为{$user}。"; } else { echo "无法更改文件所有者。"; } // 示例二:将文件的所有者更改为新用户的用户ID $filename = '/path/to/file.txt'; $user = 1001; if (lchown($filename, $user)) { echo "文件所有者已成功更改为用户ID {$user}。"; } else { echo "无法更改文件所有者。"; }
Notes: