php中scandir怎么打开,php scandir()没有显示文件 – 只显示目录

我有一个目录结构如下:

/files

/files/001

/files/001/addfile.php

/files/002

/files/002/deletefile.php

/files/003

/files/003/viewfile.php

我的剧本:

error_reporting(E_ALL);

$directory = 'files';

$files = scandir($directory);

$xml = new DOMDocument('1.0', 'UTF-8');

$xmlFiles = $xml->appendChild($xml->createElement('FILES'));

if(is_dir($directory)) {

print_r($files);

}

/*foreach($files as $file => $key) {

if($file == '.' || $file == '..') { continue; }

echo '$file: '.$file;

if(is_dir("$directory/$file")) {

$xmlDir->appendChild($xml->createElement($file));

}

else {

$xmlFiles->appendChild($xml->createElement('FILE', $file));

}

}*/

echo $xml->saveXML();

我的问题:print_r($files)输出:

Array (

[0] => .

[1] => ..

[2] => 001

[3] => 002

[4] => 003 )

为什么scandir只输出目录而不是文件?

TIA,

内特

解决方法:

你的文件在这些目录中,而scandir只显示指定路径的内容,但没有任何重复,所以一切都是正确的.

标签:php,scandir

来源: https://codeday.me/bug/20190718/1494287.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值