"; echo "File:
"; while ($file =readdir("/> "; echo "File:
"; while ($file =readdir(">

Home  >  Article  >  Backend Development  >  PHP traverses all files in XP folder

PHP traverses all files in XP folder

WBOY
WBOYOriginal
2016-07-29 08:39:16949browse

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.

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