News Tutorials Projects Reviews Authors Contact Search Links Admin
 

Reading File Directories : Useful functions

To get this script going, we need to use some key functions off php.net.

is_dir

(PHP 3, PHP 4 )

is_dir -- Tells whether the filename is a directory

Description

bool is_dir ( string filename)

Returns TRUE if the filename exists and is a directory. If filename is a relative filename, it will be checked relative to the current working directory.

opendir

(PHP 3, PHP 4 )

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. You can suppress the error output of opendir() by prepending `@' to the front of the function name.

readdir

(PHP 3, PHP 4 )

readdir -- read entry from directory handle

Description

string readdir ( resource dir_handle)

Returns the filename of the next file from the directory. The filenames are returned in the order in which they are stored by the filesystem.

closedir

(PHP 3, PHP 4 )

closedir -- close directory handle

Description

void closedir ( resource dir_handle)

Closes the directory stream indicated by dir_handle. The stream must have previously been opened by opendir(). Good code practice to close an opened file stream.

 


Author: Markavian
Last edited on: 22nd Jan, 9:14 am
Please rate this article.

« Prev page 'Introduction' « » Next Page 'Read and Output' »

tutorial Pages