php Check what files are in the directory
php Check what files are in the directory You can use opendir to open the path, and then use Just read the content and output it with readdir.
"; //先判断指定的路径是不是一个文件夹 if (is_dir($dir)){ if ($dh = opendir($dir)){ while (($file = readdir($dh))!= false){ //文件名的全路径 包含文件名 $filePath = $dir.$file; //获取文件修改时间 $fmt = filemtime($filePath); echo "(".date("Y-m-d H:i:s",$fmt).") ".$filePath."
"; } closedir($dh); } } ?>
Effect:
For more PHP related knowledge, please visitPHP Chinese website!
The above is the detailed content of php check what files are in the directory. For more information, please follow other related articles on the PHP Chinese website!