• PHP Video Tutorials

PHP - xattr set() Function



xattr_set() function can set an extended attribute.

Syntax

bool xattr_set( string $filename , string $name , string $value [, int $flags ] )

xattr_set() function can set the value of an extended attribute 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_set() function can return true on success or false on failure.

Example

<?php
   $file = "my_favourite_song.wav";
   xattr_set($file, "Artist", "Someone");
   xattr_set($file, "My ranking", "Good");
   xattr_set($file, "Listen count", "34");

   printf("You've played this song %d times", xattr_get($file, "Listen count")); 
?>
php_function_reference.htm
Advertisements