lchgrp()

1. 定义

该函数与chgrp()函数类似,它尝试修改符号链接的所属组(group)ID。 成功时返回TRUE,失败则返回FALSE。

注:该函数在Windows下无法使用(未定义)!

2. 语法

lchgrp ( string $filepath , mixed $group ) : bool

3. 参数说明

参数 可选性 数据类型 描述
$filepath 必需 字符串 要修改用户ID的文件或符号链接的路径
$group 必需 整型或字符串 所属组ID或组名

4. 示例

<?php

// lchgrp()
// 修改符号链接的所属组(group)ID

$target = __FILE__;// 该文件存在
$symlink = 'sym';
// 建立符号链接
symlink($target, $symlink);

$filepath = __DIR__.'/sym';
$user = 1;
$res = lchgrp($filepath, $user);
if($res) {
    echo '符号链接 ',$filepath, ' 的所属组ID已更改为:',$user, PHP_EOL;
} else {
    echo '符号链接的所属组ID更改失败!',"\n";
}

5. 延展阅读

  • chgrp():修改指定文件的所有者所在组的 ID
  • lchown():修改符号链接的所有者(owner)ID
  • chown():修改指定文件的所有者 ID
  • chmod():修改指定文件的访问权限