Home  >  Article  >  Backend Development  >  PHP directory php php directory operation php mkdir multi-level directory

PHP directory php php directory operation php mkdir multi-level directory

WBOY
WBOYOriginal
2016-07-29 08:55:141337browse

Directory operation

  • Create new directory
    mkdir (path, permissions, recursive creation)
  • Delete directory
    rmdir()
  • Move (rename)
    rename()
  • Get directory content
    //Open directory
    Directory handle = opendir()
    //Read directory
    File name = readdir(directory handle)
    Read the file names in sequence and move the file handle pointer downward at the same time. If it cannot be read, it returns false
    //Close directory
    closedir()

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>"&nbsp"</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 当前目录,php目录是否存在,php 目录结构,php 安装目录,php,php 目录操作,php mkdir 多级目

').addClass('pre-numbering').hide(); $(this).addClass('has-numbering').parent().append($numbering); for (i = 1; i ').text(i)); }; $numbering.fadeIn(1700); }); });

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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn