Tutorials Point


  Learning PHP
  Advanced PHP
  PHP Function Reference
  PHP Useful Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

PHP Function closedir()


previous

Advertisements

Syntax

void closedir ( resource $dir_handle );

Definition and Usage

Closes the directory stream indicated by dir_handle. The stream must have previously been opened by opendir().

Paramters

ParameterDescription
directoryRequired. The directory handle resource previously opened with opendir().

Return Value

Returns TRUE on success or FALSE on failure.

Example

Following is the usage of this function:

<?php
//Open images directory
$dir = opendir("/var/www/images");

//List files in images directory
while (($file = readdir($dir)) !== false)
{
  echo "filename: " . $file . "<br />";
}
closedir($dir);
?> 

This will produce following result:

filename: .
filename: ..
filename: logo.gif
filename: mohd.gif

previous Printer Friendly

Advertisements


  

Advertisements