Start networking and exchanging professional insights

Register now or log in to join your professional community.

Follow

Explain the working with directories using opendir(), readdirs(), closedir() in php?

user-image
Question added by Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited
Date Posted: 2016/01/26
Julfkar  Moh Umar
by Julfkar Moh Umar , Sr. Software Engineer , Aakash Edutech Private Limited

Opendir():- It opens the directory. This function returns a directory stream on success and FALSE and an error on failure.

Syntax:

Opendir(directory, context)

Context is a set of options that can modify the behavior of a stream

Example: opens sample directory.

$dir = opendir("directory");

Readdir(): It returns an entry from a directory handle opened by opendir().

Syntax:

Readdir(dir_stream)

Example:

$file = readdir($dir);

closedir(): It closes a directory handle opened by opendir().

Syntax:

closedir(dir_stream)

Example:

$file = close($dir);

More Questions Like This

Do you need help in adding the right keywords to your CV? Let our CV writing experts help you.