Directory operation
Recursively read directory contents
<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>
The above has introduced the PHP directory, including PHP and directory content. I hope it will be helpful to friends who are interested in PHP tutorials.