php獲取目標路徑(目錄)的檔案目錄的原生**,寫出來後發現還有很大的優化空間,但由於是練手的作品沒再深入修改,但這幾天都有同學問我這個問題,所以決定開通部落格,並在此獻醜,若有更優方法,也請各位不吝斧正!
閒話少說,**如下:
1 23 4
5 67 8
9 10
11 12
13 14
15 16
17 18
19 20
21 22
23 24
25 26
27 28
29 30
31 32
33 34
35 36
37 38
39 40
41 42
43 44
45 46
47 48
49 50
51 52
53 54
55 56
57 58
59 60
61 62
63 64
65 66
67 68
69 70
71 72
73 74
75 76
77 78
79 80
81 82
83 84
85 86
87 88
89 90
91 92
93 94
95 96
97 98
99 100
101102
103104
105106
<?php
classfiles
$arr[$val] =is_dir($path.$val)?'folder':'img';}}
else
return$arr;
}protectedfunctionreall($arr,$path)
else}}
return$arr;
}/**
* 函式名稱:allfiles()
* 函式作用:取得指定路徑下的所有目錄
* 引數說明:$path:指定的路徑
* 返 回 值:$result 目錄陣列 or false
*/publicfunctionallfiles($path)
return$allfiles;
}/**
* 函式名稱:dloop()
* 函式作用:雙層迴圈取得結構樹
* 引數說明:$path:指定的路徑
* 返 回 值:$result 目錄陣列 or false
*/publicfunctiondloop($arr,$path,$space=0,$spaces=0)
else
elseif(stripos($key,'.gif'))
elseif(stripos($key,'.png'))
else
$kb=round(filesize($path.$key)/1024)."k";
$str.=''.$fn.''.$kb.' ';}}
return$str;
}} ?>
PHP檔案目錄(路徑)的操作
一 解析目錄路徑 1.php程式 配置檔案 apache配置檔案中涉及路徑均使用 也可以使用目錄分隔符常量directory separator進行連線 麻煩 2.多路徑分隔符windows linux 也可以使用路徑分隔符常量path separator進行連線 3.程式換行符常量php eol ...
linux 獲取檔案路徑中的目錄路徑和檔名
經常碰到這樣的需求,需要知道執行程式的路徑和程式名,該怎麼辦呢?linux中有兩個命令 dirname 獲得檔案所在目錄名稱 basename 獲得檔案路徑中的檔名 下面我們來看看方法哈 getdir.sh path dirname 0 echo programe s file path path ...
java獲取檔案目錄或路徑
web 上執行 1 this.getclass getclassloader getresource getpath this.getclass getclassloader getresource getpath 得到的是 classpath的絕對uri路徑。如 d jboss 4.2.2.ga ...