How to use dir in PHP Directory

In this article I am going to explain about dir function in PHP.
  • 1426

PHP dir() function

The directory dir function returns an instance of the directory class. The dir function is a mechanism to read, rewind and closed a directory.

Syntax of  dir function


Parameters in dir function

It has only one parameter:

Parameter Description
directory It defines a new root directory.

Example of directory dir  function




$dir = dir("C:\wamp\www\Dinesh");


while (($file = $dir->read()) !== false)


echo "filename: " . $file . "<br />";








dir function.jpg

You may also want to read these related articles :

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here


More Articles

© 2020 DotNetHeaven. All rights reserved.