【发布时间】:2016-06-19 21:51:09
【问题描述】:
我正在使用下面的 php 来检查保存在数据库中的文件类型,但是它将所有内容显示为文件夹,我不知道问题是什么。
<?php
$path = dirname(__FILE__);
$sub_folder = scandir($path);
$num = count($sub_folder);
//$jailchillink This is the name of file saved in database replaced width index.php
if(is_file($path.'\\'.index.php)){ $codetype = 'file';}
else if(is_img($path.'\\'.index.php)){ $codetype = 'image';}
else{ $codetype = 'folder';}?>
上面的代码会输出folder
【问题讨论】:
-
调试:使用
echo或print_r在每行代码后显示每个变量或函数调用的内容。这样您就可以轻松找出问题所在。