php目录操作函数之获取目录与文件的类型
(编辑:jimmy 日期: 2024/11/20 浏览:3 次 )
复制代码 代码如下:
<?php
$dir = "./";
// Open a known directory, and proceed to read its contents
if (is_dir($dir))
{
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"."<br />";
}
closedir($dh);
}
}
?>
输出结果:
复制代码 代码如下:
filename: . : filetype: dir
filename: .. : filetype: dir
filename: cms : filetype: dir
filename: index.php : filetype: file
filename: index.php.bak : filetype: file
filename: mvc : filetype: dir
filename: shop : filetype: dir
filename: shop.rar : filetype: file
filename: xampp : filetype: dir
<?php
$dir = "./";
// Open a known directory, and proceed to read its contents
if (is_dir($dir))
{
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n"."<br />";
}
closedir($dh);
}
}
?>
输出结果:
复制代码 代码如下:
filename: . : filetype: dir
filename: .. : filetype: dir
filename: cms : filetype: dir
filename: index.php : filetype: file
filename: index.php.bak : filetype: file
filename: mvc : filetype: dir
filename: shop : filetype: dir
filename: shop.rar : filetype: file
filename: xampp : filetype: dir
下一篇:php下获取Discuz论坛登录用户名、用户组、用户ID等信息的实现代码