Query: dir
OS: php
Section: 3
Format: Original Unix Latex Style Formatted with HTML and a Horizontal Scroll Bar
DIR(3) 1 DIR(3) dir - Return an instance of the Directory classSYNOPSISDirectory dir (string $directory, [resource $context])DESCRIPTIONA pseudo-object oriented mechanism for reading a directory. The given $directory is opened.PARAMETERSo $directory - Directory to open o $context - Note Context support was added with PHP 5.0.0. For a description of contexts, refer to "Streams".RETURN VALUESReturns an instance of Directory, or NULL with wrong parameters, or FALSE in case of another error.EXAMPLESExample #1 dir(3) example Please note the fashion in which Directory.read(3)'s return value is checked in the example below. We are explicitly testing whether the return value is identical to (equal to and of the same type as - see Comparison Operators for more information) FALSE since otherwise, any directory entry whose name evaluates to FALSE will stop the loop. <?php $d = dir("/etc/php5"); echo "Handle: " . $d->handle . " "; echo "Path: " . $d->path . " "; while (false !== ($entry = $d->read())) { echo $entry." "; } $d->close(); ?> The above example will output something similar to: Handle: Resource id #2 Path: /etc/php5 apache cgi cliNOTESNote The order in which directory entries are returned by the read method is system-dependent. PHP Documentation Group DIR(3)
Related Man Pages |
---|
tempnam(3) - php |
readdir(3) - php |
mkdir(3) - php |
ftp_chdir(3) - php |
zip_entry_open(3) - php |
Similar Topics in the Unix Linux Community |
---|
need Script logic |
Moving files from one directory to another based on 2 date variables |
Solaris,PHP,Expect support |
Formatted Directory Listing Question |
Find Command Include Sub Directory |