PHP closedir

Education is not limited to just classrooms. It can be gained anytime, anywhere... - Ravi Ranjan (M.Tech-NIT)

PHP : closedir() function

Description

The closedir() function is used to close a directory handle previously been opened by the opendir() function.

Version

(PHP 4 and above)

Syntax

closedir(dir_handle)

Parameter

Name

Description

Required /
Optional

Type

dir_handle

Specifies the directory handle to close

Required

Resource

Example :

  1. $dir_name = opendir("test");  

  2. while (($file = readdir($dir_name)) !== false)  

  3. {  

  4. echo "filename: " . $file . "
    ";  

  5. }  

  6. closedir($dir_name);  

  7. ?>