php目录操作函数之获取目录与文件的类型

前端之家收集整理的这篇文章主要介绍了php目录操作函数之获取目录与文件的类型前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

<div class="codetitle"><a style="CURSOR: pointer" data="1566" class="copybut" id="copybut1566" onclick="doCopy('code1566')"> 代码如下:

<div class="codebody" id="code1566">
<?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"."
";
}
closedir($dh);
}
}
?>

输出结果:
<div class="codetitle"><a style="CURSOR: pointer" data="93280" class="copybut" id="copybut93280" onclick="doCopy('code93280')"> 代码如下:
<div class="codebody" id="code93280">
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

原文链接:https://www.f2er.com/php/28234.html

猜你在找的PHP相关文章