php8.5
Home/ Manual/ xattr / functions/ xattr_get

xattr_get

PHP function Edit on GitHub ✎

(PECL xattr >= 0.9.0)

Get an extended attribute

Description

xattr_get(string $filename, string $name, int $flags = 0): string|false

This function gets the value of an extended attribute of a file.

Namespace

Parameters

filename

The file from which we get the attribute.

name

The name of the attribute.

flags
XATTR_DONTFOLLOWDo not follow the symbolic link but operate on symbolic link itself.
XATTR_ROOTSet attribute in root (trusted) namespace. Requires root privileges.

Return Values

Returns a string containing the value or false if the attribute doesn't exist.

Examples

Checks if system administrator has signed the file

php
<?php
$file = '/usr/local/sbin/some_binary';
$signature = xattr_get($file, 'Root signature', XATTR_ROOT);

/* ... check if $signature is valid ... */

?>

See Also

Source: reference/xattr/functions/xattr-get.xml · from the official PHP manual (php/doc-en)