php代碼:實現(xiàn)當(dāng)前目錄文件列表列出
來源:程序員人生 發(fā)布時間:2014-03-06 22:08:45 閱讀次數(shù):3681次
建站學(xué)院(LieHuo.Net)網(wǎng)絡(luò)編程 關(guān)于php實現(xiàn)列出當(dāng)前文件列表的方法,網(wǎng)上有很多,近日liehuo.net的小編綜合了網(wǎng)上的一些資料, 改寫了一下,感覺這是最佳的方法,特別將代碼公布出來。
以下為引用的內(nèi)容: <?php function tree($directory) { echo date(”Y-m-d H:i:s”); $i=0; $mydir=dir($directory); echo “<ul>”; while($file=$mydir->read() AND $i<5) { if((is_dir(”$directory”)) AND ($file!=”.”) AND ($file!=”..”)) { $filetime=date(”Y-m-d H:i:s”,filectime($file)); //encode spaces $file = rawurlencode($file); // convert the + (this is one result from the function rawurlencode) in %20 $url = str_replace(’+’ , ‘%20′ , $file); echo “<li><font color=”#ff00cc”><a href=’”.$url.”‘>”.$url.”</a></font> $filetime<br/></li>”; $i+=1; } } echo “</ul>”; $mydir->close(); } tree(”.”); // 列出當(dāng)前目錄 ?> |
生活不易,碼農(nóng)辛苦
如果您覺得本網(wǎng)站對您的學(xué)習(xí)有所幫助,可以手機(jī)掃描二維碼進(jìn)行捐贈