Jump to content
  • Hello visitors, welcome to the Hacker World Forum!

    Red Team 1949  (formerly CHT Attack and Defense Team) In this rapidly changing Internet era, we maintain our original intention and create the best community to jointly exchange network technologies. You can obtain hacker attack and defense skills and knowledge in the forum, or you can join our Telegram communication group to discuss and communicate in real time. All kinds of advertisements are prohibited in the forum. Please register as a registered user to check our usage and privacy policy. Thank you for your cooperation.

    TheHackerWorld Official

Recommended Posts

文件目录操作

创建&关闭&删除

# 将文件读入一个字符串 file_get_contents()
# 向文件中写入数据 fwrite()、file_put_contents()
# 创建目录 mkdir()
# 删除 unlink()
# 删除目录 rmdir()

查&改

# 打开和关闭文件 fopen()、fclose()
# 创建临时文件 tmpfile(),关闭临时文件fclose()
# 读取文件内容 fread()
# 从文件中读取一个字符 fgetc()
# 逐行读取文件 gets()、fgetss()
# 读取全部文件 readfile()
# 把整个文件读入一个数组中 file()
# 获取文件属性
## 检查文件或目录是否存在file_exists()
## 获取文件大小 filesize()
# 是否是目录 is_dir()
# 打开目录 opendir(),关闭目录 closedir()
# 读取目录下的文件及文件夹 readdir()、scandir()
# 重命名文件 rename()
# 复制文件 copy() 

遍历文件夹下所有文件和文件夹

function my_scandir($dir) {
    $files = [];
    if($handle = opendir($dir)) {
        while(($file = readdir($handle)) !== false) {
            if($file != ".." && $file != ".") {
                if(is_dir($dir."/".$file)) {
                    $files[$file] = scandir($dir."/".$file);
                } else {
                    $files[] = $file;
                }
            }
        }
        closedir($handle);
        return $files;
    }
}
Link to post
Link to comment
Share on other sites

 Share

discussion group

discussion group

    You don't have permission to chat.
    • Recently Browsing   0 members

      • No registered users viewing this page.
    ×
    ×
    • Create New...