• PHP Video Tutorials

PHP - xattr list() Function



xattr_list() function can get a list of extended attributes.

Syntax

array xattr_list( string $filename [, int $flags = 0 ] )

xattr_list() function can get a list of names of extended attributes of a file.

The extended attributes have two different namespaces: user and root. The user namespace can be available to all users, while a root namespace is available only to users with root privileges. xattr can operate on a user namespace by default, but we can change it by using the flags argument.

xattr_list() function can return an array with names of extended attributes.

Example

<?php
   $file = "some_file";
   $root_attributes = xattr_list($file, XATTR_ROOT);
   $user_attributes = xattr_list($file);

   echo "Root attributes: \n";
   foreach($root_attributes as $attr_name) {
      printf("%s\n", $attr_name);
   }

   echo "\n User attributes: \n";
   foreach ($attributes as $attr_name) {
      printf("%s\n", $attr_name);
   }
?>
php_function_reference.htm
Advertisements