What we are here to introduce to you is
- < ?php
- $base_dir = "filelist/"; > =
- opendir($base_dir); echo $base_dir."<
- hr/> " ; while($flist=
-
readdir($fso)){ echo $flist."<
- br/>" ; } closedir($fso)
-
?>
-
- This means returning the files under the file directory. Directory program (0 files will return false).
- Sometimes PHP reading directory function needs to know the directory information. You can use dirname($path) and basename($path) to return the directory part of the path respectively. and the file name part, you can use disk_free_space($path) to return the free space. Creation command:
mkdir($path,0777)
, 0777 is the permission code, it can be set with the umask() function under non-window conditions.
rmdir($path)
will delete files with paths in $path.
dir -- directory class It is also an important class for operating file directories. It has three methods, read, rewind, and close. This is a pseudo-object-oriented class. It first uses a file handle to open the file, and then reads it using a pointer. Here is PHP How the manual describes the PHP read directory function:
Output:
Handle: Resource id #2
Path : /etc/php5
.
..
<ol class="dp-xml">
<li class="alt"><span><span class="tag"><</span><span> ?php </span></span></li><li><span>$</span><span class="attribute">d</span><span> = </span><span class="attribute-value">dir</span><span>("/etc/php5"); </span></li><li class="alt"><span>echo "Handle: " . <br />$d-</span><span class="tag">></span><span>handle . "n"; </span></span></li>
<li>
<span>echo "Path: " . <br>$d-</span><span class="tag">></span><span>path . "n"; </span>
</li>
<li class="alt">
<span>while (false !== <br>($</span><span class="attribute">entry</span><span> = $d-</span><span class="tag">></span><span>read())) { </span>
</li>
<li><span>echo $entry."n"; </span></li>
<li class="alt"><span>} </span></li>
<li>
<span>$d-</span><span class="tag">></span><span>close(); </span>
</li>
<li class="alt">
<span class="tag">?></span><span> </span>
</li>
<li><span> </span></li>
</ol>
apache
cgi
cli
The attributes of the file are also very important for the PHP reading directory function. The file attributes include creation time , last modified time, owner, file group, type, size, etc.
http://www.bkjia.com/PHPjc/445977.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/445977.html
TechArticleWhat we introduce to you here is?php $ base_dir = filelist/ ; $ fso = opendir ($base_dir) ; echo$base_dir. hr / ; while($ flist = readdir ($fso)){ echo$flist. br / ; } closedir...
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn