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

xattr_remove

PHP function Edit on GitHub ✎

(PECL xattr >= 0.9.0)

Remove an extended attribute

Description

xattr_remove(string $filename, string $name, int $flags = 0): bool

This function removes an extended attribute of a file.

Namespace

Parameters

filename

The file from which we remove the attribute.

name

The name of the attribute to remove.

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

Success

Examples

Removes all extended attributes of a file

php
<?php
$file = 'some_file';
$attributes = xattr_list($file);

foreach ($attributes as $attr_name) {
    xattr_remove($file, $attr_name);
}
?>

See Also

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