Dosya Sistemi İşlevleri
PHP Manual

fileperms

(PHP 4, PHP 5)

fileperms — Dosya izinlerini döndürür

Açıklama

int fileperms ( string $dosyaismi )

Belirtilen dosya ile ilgili izinleri döndürür.

Değiştirgeler

dosyaismi

Dosya yolu.

Dönen Değerler

Bir hata durumunda FALSE, aksi takdirde dosyanın izinlerini döndürür.

Örnekler

Örnek 1 - İzinlerin sekizlik değer olarak gösterilmesi

<?php
echo substr(sprintf('%o', fileperms('/tmp')), -4);
echo 
substr(sprintf('%o', fileperms('/etc/passwd')), -4);
?>

Yukarıdaki örneğin çıktısı:

1777
0644

Örnek 2 - Tüm izinlerin gösterilmesi

<?php
$perms 
= fileperms('/etc/passwd');

if ((
$perms & 0xC000) == 0xC000) {
    
// Soket
    
$info = 's';
} elseif ((
$perms & 0xA000) == 0xA000) {
    
// Sembolik bağ
    
$info = 'l';
} elseif ((
$perms & 0x8000) == 0x8000) {
    
// Sıradan dosya
    
$info = '-';
} elseif ((
$perms & 0x6000) == 0x6000) {
    
// Blok aygıtı
    
$info = 'b';
} elseif ((
$perms & 0x4000) == 0x4000) {
    
// Dizin
    
$info = 'd';
} elseif ((
$perms & 0x2000) == 0x2000) {
    
// Karakter aygıtı
    
$info = 'c';
} elseif ((
$perms & 0x1000) == 0x1000) {
    
// FIFO boru
    
$info = 'p';
} else {
    
// Bilinmiyor
    
$info = 'u';
}

// Kullanıcı
$info .= (($perms & 0x0100) ? 'r' : '-');
$info .= (($perms & 0x0080) ? 'w' : '-');
$info .= (($perms & 0x0040) ?
            ((
$perms & 0x0800) ? 's' : 'x' ) :
            ((
$perms & 0x0800) ? 'S' : '-'));

// Grup
$info .= (($perms & 0x0020) ? 'r' : '-');
$info .= (($perms & 0x0010) ? 'w' : '-');
$info .= (($perms & 0x0008) ?
            ((
$perms & 0x0400) ? 's' : 'x' ) :
            ((
$perms & 0x0400) ? 'S' : '-'));

// Herkes
$info .= (($perms & 0x0004) ? 'r' : '-');
$info .= (($perms & 0x0002) ? 'w' : '-');
$info .= (($perms & 0x0001) ?
            ((
$perms & 0x0200) ? 't' : 'x' ) :
            ((
$perms & 0x0200) ? 'T' : '-'));

echo 
$info;
?>

Yukarıdaki örneğin çıktısı:

-rw-r--r--

Notlar

Bilginize: Bu işlevin sonuçları önbelleğe kaydedilir. Daha ayrıntılı bilgi edinmek için clearstatcache() işlevine bakınız.

İpucu

PHP 5.0.0 sürümünden itibaren bu işlev bazı URL sarmalayıcıları ile kullanılabilmektedir. stat() ailesini destekleyen sarmalayıcıların listesini Supported Protocols and Wrappers başlığı altında bulabilirsiniz.

Ayrıca Bakınız


Dosya Sistemi İşlevleri
PHP Manual