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:

'; echo readdir($dh).'
'; echo readdir($dh).'
'; echo readdir($dh).'
'; //读取到最后返回false //关闭文件夹资源 closedir($dh); } } ?>
##opendir Open the folder and return to the operation resource readdir Read folder resources is_dir Determine whether it is a folder closedir Close folder operation resources filetype Displays whether it is a folder or a file, the file displays file, and the folder displays dir
Function name Function
Since we read once and move backward once, can we

"; } closedir($dh); } } ?>


Continuing Learning
||
'; echo readdir($dh).'
'; echo readdir($dh).'
'; echo readdir($dh).'
'; //读取到最后返回false //关闭文件夹资源 closedir($dh); } } ?>
submit Reset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!