我必须检查我的文件夹资产/文件是否为空,以显示创建新文件的消息或列出我的文件夹中的所有文件..但我的文件夹是空的,我收到消息"你有文件"..
<?php
/**
* FileExist
* check files
* @return no
*/
public function fileExist()
{
$open = "../asset/files";
if (scandir($open)) {
echo "`You got files";
print_r(scandir($open));
} else {
echo "You haven't got files";
}
}
?>
Run Code Online (Sandbox Code Playgroud)
这应该适合你:
(这里我只是glob()用来获取目录的所有文件并检查它是否为空.你的方法没有用,因为scandir()还包括.和..)
public function fileExist()
{
$open = "../asset/files";
if ($files = glob($open . "/*")) {
echo "You got files";
print_r($files);
} else {
echo "You haven't got files";
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3046 次 |
| 最近记录: |