ChDir: Change the directory.
Dir: Catalog Category class.
Closedir: Close directory handle.
Opendir: Open Directory handle.
Readdir: Read directory handle.
Rewinddir: Reset directory handle.
ChDir
Change the directory.
Syntax: int chdir (string directory);
return value: Integer
Function Type: File access
Content Description This function is used to change the current PHP execution directory into the new directory directory. Returns False if it cannot be changed, and returns True if it succeeds.
Dir
Directory category class.
Syntax: New dir (string directory);
Return value: Class
Function Type: File access
Content Description This is an object-oriented category class that is used to read directories. When directory parameter directory is open, there are two properties available: The Handle property is like the Readdir (), Rewinddir (), and Closedir () used by other non-class functions, and the Path property configures the route parameters after opening the directory. This class has three methods: Read, rewind, and close.
Usage examples
?
$d = Dir ("/etc");
echo "Handle:". $d->handle. " <br>n ";
echo "Path:" $d->path. " <br>n ";
while ($entry = $d->read ()) {
echo $entry. " <br>n ";
}
$d->close ();
?>
Closedir
Closes the directory handle.
Syntax: void closedir (int dir_handle);
return value: None
Function Type: File access
Content Description
This function is used to close the dir_handle of the directory data stream. The directory to which this dir_handle parameter operates must be Opendir () open.
Opendir
Open the directory handle.
Syntax: int opendir (string path);
return value: Integer
Function Type: File access
Content Description
This function is used to open the directory data stream. The returned integer is a handle that can be manipulated by other directory functions.
Readdir
Read the directory handle.
Syntax: string readdir (int dir_handle);
return value: String
Function Type: File access
Content Description This function is used to read the directory. Returns the name of the file in the directory, reading in no extraordinary order.
Use the example to list all the files in the current directory
<?php
$handle =opendir ('. ');
echo "Directory handle: $handle";
echo "File:";
while ($file = Readdir ($handle)) {
echo "$file";
}
Closedir ($handle);
?>
Rewinddir
Resets the directory handle.
Syntax: void rewinddir (int dir_handle);
return value: None
Function Type: File access
Content Description This function is used to reset the directory data stream to the beginning.