"; echo "File:
"; while ($file =readdir("/>
"; echo "File:
"; while ($file =readdir(">
Home > Article > Backend Development > PHP traverses all files in XP folder
Copy the code The code is as follows:
//PHP traverses all files in the folder
$handle=opendir( 'C:\'); //I want to traverse the files on the C drive
echo "Directory handle: $handle
";
echo "File:
";
while ($file =readdir($handle)) {
$file=iconv('GB2312','UTF-8',$file);//Convert XP's gbk encoding to UTF8
echo "$file
" ; //Output file name
}
closedir($handle);
?>
The above introduces PHP to traverse all files in the XP folder, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.