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

dir(directory)

Parameters in dir function

It has only one parameter:

Parameter Description
directory It defines a new root directory.

Example of directory dir  function

<html>

<body>
 

<?php

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

 

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

{

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

}

$dir->close();

?>
 

</body>

</html>

 

Output:

dir function.jpg

You may also want to read these related articles :
here

Ask Your Question 

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

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.