我使用 scandir() 递归搜索文件。但如果文件路径指向文件而不是文件夹,则会出现警告。如何检查路径是否指向文件或文件夹?
enter code here
<?php
$path = "C:\\test_folder\\folder2\\folder4";
$sub_folder = scandir($path);
$num = count($sub_folder);
for ($i = 2; $i < $num; $i++)
{
...//if $sub_folder[$i] is a file but a folder, there will be a warning.
How can I check $sub_folder[$i] before use it?
}
?>
谢谢!