国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

php directory processing function

Before we dealt with all files, how to deal with directories and folders?

Let’s learn the functions related to the processing of directories or folders.

The basic idea of ??processing folders is as follows:

1. When reading a certain path, determine whether it is a folder

2. If it is a folder, open the specified file Folder, return the resource variable of the file directory

3. Use readdir to read the file in the directory once, and the directory pointer will be offset backward once

4. Use readdir to read to the end, there is no available The read file returns false

5. Close the file directory

Let’s learn a list of commonly used functions:

##opendirOpen the folder and return to the operation resourcereaddirRead folder resourcesis_dirDetermine whether it is a folderclosedirClose folder operation resourcesfiletypeDisplays whether it is a folder or a file, the file displays file, and the folder displays dir
<?php
//設(shè)置打開的目錄是D盤
$dir = "d:/";

//判斷是否是文件夾,是文件夾
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {

      //讀取一次向后移動一次文件夾指針
      echo readdir($dh).'<br />';
      echo readdir($dh).'<br />';
      echo readdir($dh).'<br />';
      echo readdir($dh).'<br />';

      //讀取到最后返回false

      //關(guān)閉文件夾資源
       closedir($dh);
   }
}
?>
Function name Function
Since we read once and move backward once, can we

<?php
//設(shè)置打開的目錄是D盤
$dir = "d:/";

//判斷是否是文件夾,是文件夾
if (is_dir($dir)) {
   if ($dh = opendir($dir)) {


      //讀取到最后返回false,停止循環(huán)
      while (($file = readdir($dh)) !== false) {
           echo "文件名為: $file : 文件的類型是: " . filetype($dir . $file) . "<br />";
       }

       closedir($dh);
   }
}
?>


Continuing Learning
||
<?php //設(shè)置打開的目錄是D盤 $dir = "d:/"; //判斷是否是文件夾,是文件夾 if (is_dir($dir)) { if ($dh = opendir($dir)) { //讀取一次向后移動一次文件夾指針 echo readdir($dh).'<br />'; echo readdir($dh).'<br />'; echo readdir($dh).'<br />'; echo readdir($dh).'<br />'; //讀取到最后返回false //關(guān)閉文件夾資源 closedir($dh); } } ?>
submitReset Code