目錄操作
遞歸讀取目錄內容
<code><span><?php</span> showDir(<span>'../../file'</span>); <span><span>function</span><span>showDir</span><span>(<span>$path</span>,<span>$dep</span>=<span>0</span>)</span>{</span><span>$pos</span> = opendir(<span>$path</span>); <span>while</span>(<span>false</span>!==<span>$file</span>=readdir(<span>$pos</span>)){ <span>if</span>(<span>$file</span>==<span>'.'</span>||<span>$file</span>==<span>'..'</span>) <span>continue</span>; <span>echo</span> str_repeat(<span>" "</span>,<span>$dep</span>*<span>4</span>),<span>$file</span>.<span>'</br>'</span>; <span>if</span>(is_dir(<span>$path</span>.<span>'/'</span>.<span>$file</span>)){ <span>$func</span> = <span>__FUNCTION__</span>; <span>$func</span>(<span>$path</span>.<span>'/'</span>.<span>$file</span>,<span>$dep</span>+<span>1</span>); } } }</code>
以上就介紹了PHP之目錄,包括了php,目錄方面的內容,希望對PHP教程有興趣的朋友有幫助。