作者rushcat (嗯)
看板PHP
标题[请益] 有关於档案存取的函式
时间Fri May 4 00:39:34 2007
想自己写个简单的相簿 从特定资料夹读图片名称 然後显示出来
<?PHP
$handle = opendir("./pictures");
echo "File".$handle."<br>";
while ( $file = readdir($handle)){
if(!file_exists($file)){
echo "<img src= \"pictures/".$file."\" width=300 /><br>";
echo "$file <br><br><br><br>" ;
}
}
closedir($handle);
?>
黄色的判断式是後来才加的
没加之前 $file会跑出两个奇怪的名称 "." ".." 应该是路径 但是不知道怎麽去掉
曾经用过if($file!="." && $file!="..")来过滤 但觉得怪怪的
後来找到file_exits 但是发现 必须用
!file_exists($file)才会通过
一整个不懂为什麽...orz
--
◢ █◣ ◢◢◣ ◢◣◥████
◢███◣ ◢ ◣ █╴█╴█ ████
███▉█ ◢█◢ ◣◢ ██ ≡███≡ ◥█
███▉█ ◢▉█ ◢██ ███ ◢██ ◢██ ███ ◥█﹋█◤ ◎ █
█▇▇▇◤ █▉█ █▇▇ █▇▏ ▉▇▇ █▉█ ██ ▉▉█▏▏/ ◢█
██▇▏◣ █▇█ ▇▇█ ██▏ ███ █▇█▎██ █▉▉█▏▏█ rushcat
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 140.119.199.250
1F:推 readper:.是本资料夹 ..是上层资料夹 05/04 00:44