NOVINKA: Najžiadanejšie rekvalifikačné kurzy teraz s 50% zľavou + kurz AI ZADARMO. Nečakaj, táto ponuka dlho nevydrží! Zisti viac:

PHP - dir

Trieda

Koreň \ Bez triedy

Metóda - dir

(PHP 4, PHP 5, PHP 7)

The dir() function is used to get an instance of the Directory class which we can be used for reading a directory.

Note: The order in which the directory entries are returned (when calling the read() method) depends on the operating system.

Procedurálne

  • function dir (string $directory, resource $context) : Directory

Parametre

NázovDátový typPredvolená hodnotaPopis
$directorystring

The path to the directory.

$contextresource

The context contains parameters and options, that affect the behavior of the stream.

Mávratovej hodnoty

Vracia: Directory

Returns an instance of the Directory class or null with wrong parameters. Returns false if an error occurs.

Príklady

<?php
$directory = dir('../'); // getting an instance of the Directory class

echo 'Path: ' . $directory->path . '<br>';
echo 'Contents:<br>';

// reading individual entries (file names, folder names)
while ($entry = $directory->read()) {
    echo $entry.'<br>';
}

$directory->close(); // closing the directory

Súvisiace manuály

        Aktivity