PHP Directory management function Summary _php tips
Source: Internet
Author: User
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.
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, which is not in any particular order.
Use the example to list all the files in the current directory
<?php
$handle =opendir ('. ');
echo "directory handle: $handle \ n";
echo "file: \ n";
while ($file = Readdir ($handle)) {
echo "$file \ n";
}
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.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.
A Free Trial That Lets You Build Big!
Start building with 50+ products and up to 12 months usage for Elastic Compute Service