Home  >  Article  >  Backend Development  >  PHP directory operation function to obtain the type of directory and file_PHP tutorial

PHP directory operation function to obtain the type of directory and file_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:32:42809browse

复制代码 代码如下:

$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);
}
}
?>

输出结果:
复制代码 代码如下:

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/322757.htmlTechArticle复制代码 代码如下: ?php $dir = "./"; // Open a known directory, and proceed to read its contents if (is_dir($dir)) { if ($dh = opendir($dir)) { while (($file = readdir($dh)...
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