closedir

(PHP 4, PHP 5, PHP 7, PHP 8)

closedirDizin tanıtıcısını kapatır

Açıklama

closedir(resource $dizin_tanıtıcısı = ?): void

dizin_tanıtıcısı ile belirtilen dizin akımını kapatır. Akımın evvelce opendir() tarafından açılmış olması gerekir.

Değiştirgeler

dizin_tanıtıcısı

opendir() işlevinden dönmüş bir dizin tanıtıcısı. Belirtilmezse opendir() tarafından açılan son dizin kullanılır.

Dönen Değerler

Hiçbir değer dönmez.

Örnekler

Örnek 1 - closedir() örneği

<?php
$dizin 
"/etc/apache2/";

// Dizin aç ve içeriğin oku
if (is_dir($dizin)) {
    if (
$dit opendir($dizin)) {
        while ((
$dosya readdir($dit)) !== false) {
          echo 
"dosya adı: $dosya - dosya türü: " .
            ((
filetype($dizin $dosya) === "dir") ? "dizin" "dosya") . "\n";
        }
        
closedir($dit);
    }
}
?>

add a note add a note

User Contributed Notes 1 note

up
-28
foo at bar dot com
23 years ago
About deleting a directory after doing a readdir/closedir on it... I'm not sure if this is the solution, but you could try to chdir("/"); before the rmdir to make absolutely sure you aren't standing in the directory (i.e trying to pull out the rug from under yourself).
To Top