當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


PHP xattr_set()用法及代碼示例


xattr_set() 函數可以設置擴展屬性。

用法

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

xattr_set() 函數可以設置文件擴展屬性的值。

擴展屬性有兩個不同的命名空間:user 和 root。用戶命名空間可供所有用戶使用,而根命名空間僅適用於具有 root 權限的用戶。默認情況下,xattr 可以對用戶命名空間進行操作,但我們可以使用 flags 參數更改它。

xattr_set() 函數可以在成功時返回 true 或在失敗時返回 false。

示例

<?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 - xattr set() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。