phpday 2027 - Call for Papers

filegroup

(PHP 4, PHP 5, PHP 7, PHP 8)

filegroup — Gets file group

Опис

function filegroup(string $filename): int|false

Gets the file group. The group ID is returned in numerical format, use posix_getgrgid() to resolve it to a group name.

Параметри

filename

Path to the file.

Значення, що повертаються

Returns the group ID of the file, or false if an error occurs. The group ID is returned in numerical format, use posix_getgrgid() to resolve it to a group name. Upon failure, false is returned.

Помилки/виключення

Upon failure, an E_WARNING is emitted.

As of PHP 8.6.0, a ValueError is thrown if filename contains NUL bytes.

Журнал змін

Версія Опис
8.6.0 Now throws a ValueError when filename contains NUL bytes.

Приклади

Приклад #1 Finding the group of a file

<?php
$filename = 'index.php';
print_r(posix_getgrgid(filegroup($filename)));
?>

Примітки

Зауваження:

Рузультати цієї функції кешуються. Докладніше: clearstatcache().

Підказка

Починаючи з PHP 5.0.0, ця функція також може бути використана з деякими URL-обгортками. На сторінці Підтримувані протоколи та обгортки вказано, які обгортки підтримують сімейство функцій stat().

Прогляньте також

+add a note

User Contributed Notes 1 note

up
0
chris at ocproducts dot com
6 years ago
This function will always return 0 on Windows, because Windows does not support numeric group IDs.
To Top