Comunitatea PHP Romania
 

 
opendir

opendir

(PHP 3, PHP 4 , PHP 5)

opendir -- open directory handle

Description

resource opendir ( string path)

Returns a directory handle to be used in subsequent closedir(), readdir(), and rewinddir() calls.

If path is not a valid directory or the directory can not be opened due to permission restrictions or filesystem errors, opendir() returns FALSE and generates a PHP error of level E_WARNING. You can suppress the error output of opendir() by prepending '@' to the front of the function name.

Exemplu 1. opendir() example

<?php
$dir
= "/tmp/";

// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
    if (
$dh = opendir($dir)) {
        while ((
$file = readdir($dh)) !== false) {
            echo
"filename: $file : filetype: " . filetype($dir . $file) . "\n";
        }
        
closedir($dh);
    }
}
?>

As of PHP 4.3.0 path can also be any URL which supports directory listing, however only the file:// URL wrapper supports this in PHP 4.3. As of PHP 5.0.0, support for the ftp:// URL wrapper is included as well.

See also is_dir(), readdir(), and Dir

Ultimele discutii in forum RSS Forum

Ultimele articole Ultimele articole

Top membri

Pirahna Pirahna
acasa , in pat
carco carco
Bucuresti
Birkoff Birkoff
Bucuresti
Mascka Mascka
Braila
raul_ raul_
whooper whooper
Toronto ON
mihaitha mihaitha
Sibiu
gabysolomon gabysolomon
Bacau
oriceon oriceon
Constanta
garlicinicolae garlicinicolae

Newsletter


Email:
 inscriere
 renuntare
 
 Arhiva newsletter

Parteneriat

Copyright © 2001-2008 PHP Romania Add PHPRomania to Google Add PHPRomania to Del.icio.us Add PHPRomania to Stumbleupon Add PHPRomania to Yahoo! Add PHPRomania to Digg Add PHPRomania to Blink Credit Cards | Free Advertising | Loans | Cheap Flights | Adverse Credit Remortgage
Ads: Partener Way2Web Nework: gazduire web | inregistrare domenii | web design | imobiliare | web hosting
Powered by Simplis