• PHP Video Tutorials

PHP - xattr Functions

The xattr extension can allow for the manipulation of extended attributes on a filesystem.

To use xattr, we can need a libattr installed.

These functions can only work on filesystems that support extended attributes and have enabled at mount time. Some common filesystems that support extended attributes: ext2, ext3, reiserfs, jfs, and xfs.

This extension doesn't have configuration directives defined in php.ini.

This extension has no resource types defined.

Predefined Constants

The constants are defined below by this extension and can only be available when an extension has either compiled into PHP or dynamically loaded at runtime.

  • XATTR_ROOT (integer) − Set attribute in root (trusted) namespace. Requires root privileges.
  • XATTR_DONTFOLLOW (integer) − Do not follow the symbolic link but operate on symbolic link itself.
  • XATTR_CREATE (integer) − Function will fail if extended attribute already exists.
  • XATTR_REPLACE (integer) − Function will fail if extended attribute doesn't exist.
Sr.No Function & Description
1 xattr_get()

Function can get an extended attribute.

2 xattr_list()

Function can get a list of extended attributes.

3 xattr_remove()

Function can remove an extended attribute.

4 xattr_set()

Function can set an extended attribute.

5 xattr_list()

Function can check if filesystem support extended attributes.