函式名:filegroup()
函式描述:filegroup() 函式用於獲取檔案的所屬組。
用法:string filegroup(string $filename)
引數:
- $filename:必需,要獲取所屬組的檔案路徑。
返回值:返回檔案的所屬組名稱,如果獲取失敗則返回 false。
示例:
<?php
$filename = 'example.txt';
$group = filegroup($filename);
if ($group !== false) {
echo "檔案 $filename 的所屬組是:$group";
} else {
echo "無法獲取檔案的所屬組";
}
?>
以上示例將輸出類似以下內容:
檔案 example.txt 的所屬組是:www-data
注意事項:
- 在 Windows 系統上,filegroup() 函式不支援 NTFS 檔案系統,因此無法獲取檔案的所屬組。
- 在 Unix 和 Linux 系統上,需要有足夠的許可權才能獲取檔案的所屬組資訊。
- 如果檔案不存在或者無法獲取檔案資訊,filegroup() 函式將返回 false。
- 如果需要獲取檔案的所有者資訊,請使用 fileowner() 函式。