php显示错误内容为空,检查文件夹是否为空输出错误(PHP)
opendir用于打開(kāi)目錄,而不是文件:-)
您還可以嘗試暫時(shí)調(diào)試調(diào)試內(nèi)容,以便了解正在發(fā)生的事情:
function IsNotEmpty ($folder) {
$files = array ();
if ($handle = opendir ($folder)) {
echo "DEBUG opened okay ";
while (false !== ($file = readdir ($handle))) {
if ( $file != "." && $file != ".." ) {
$files [] = $file;
echo "DEBUG got a file ";
}
}
closedir ($handle);
} else {
echo "DEBUG cannot open ";
}
return (count($files) > 0 ) ? TRUE : FALSE;
}
$dir ="/Site/images/countries/abc/a";
if (IsNotEmpty($dir)) {
echo "There is no such file";
} else {
echo "The file exists!";
}如果仍然無(wú)法正常工作,并且您確定該目錄存在(請(qǐng)記住,案例對(duì)UNIX很重要),您可能需要查看該目錄的權(quán)限,以確保允許嘗試訪問(wèn)該目錄的用戶(hù)ID。
總結(jié)
以上是生活随笔為你收集整理的php显示错误内容为空,检查文件夹是否为空输出错误(PHP)的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: php中 param,php中bind_
- 下一篇: 动态规划算法php,php算法学习之动态