Rmdir ($ path)
The file with the path in $ path will be deleted .(
First, we will introduce a function that reads data from a directory, such as opendir (), readdir (), and closedir (). When using this function, we will first open the file handle and then list it through iteration:
| The code is as follows: |
Copy code |
<? Php
$ Base_dir = "filelist /";
$ Fso = opendir ($ base_dir );
Echo $ base_dir. "While ($ flist = readdir ($ fso )){
Echo $ flist. "<br/> ";
}
Closedir ($ fso)
?> |
This is a program that returns the files under the file directory that are already in the Directory (0 files will return false ).
If you need to know the directory information, you can use dirname ($ path) and basename ($ path) to return the directory and file name respectively. disk_free_space ($ path) is available) returns the free space of the viewing space.
Create Command:
Mkdir ($ path, 0777)
, 0777 is the permission code, which can be set by the umask () function in a non-window environment.
Rmdir ($ path)
The file with the path in $ path will be deleted.
The dir -- directory class is also an important class for operating file directories. It has three methods: read, rewind, and close. This is an object-oriented class. It first uses open file handles, and then read it by pointer ., see the php manual here:
| The code is as follows: |
Copy code |
<? Php
$ D = dir ("/etc/php5 ");
Echo "handle:". $ d-> handle ."";
Echo "path:". $ d-> path ."";
While (false! ==( $ Entry = $ d-> read ())){
Echo $ entry ."";
}
$ D-> close ();
?> |
Output:
| The code is as follows: |
Copy code |
Handle: resource id #2
Path:/etc/php5
.
..
Apache
Cgi
Cli |
File attributes are also very important. File attributes include creation time, last modification time, owner, file Group, type, size, etc.
Next we will focus on file operations.