zhiqingstudy

Be a young person with knowledge and content

PHP folder operation, creating, reading, deleting, judging, and closing folder methods.

<?php
// 1.创建文件夹
mkdir('./aa');
mkdir('./aa/bb'); //在aa文件夹下创建bb文件,aa文件夹必须存在

// 创建文件夹【mkdir(路径,权限,是否递归创建)】
mkdir('./aa/bb/cc/dd',0777,true);// 0777表示目录权限,true代表递归创建,文件夹不存在就创建

// 2.删除文件夹
rmdir('./aa/bb/cc/dd'); //删除dd文件夹,文件夹必须是空的

// 3.重命名文件夹
rename('./aa','./aaa');

// 4.是否是文件夹
echo is_dir('./aaa') ? '是文件夹':'不是文件夹';

// 5.打开文件夹、读取文件夹、关闭文件夹
$folder=opendir('./'); // 打开当前目录
var_dump($folder);

// 读取文件夹
while($f=readdir($folder)){
    echo $f,'<br>';
}
// 关闭文件夹
closedir($folder);
?>
comment
head sculpture
Code:
Related

The art of interpersonal communication and communication

A code of conduct that regulates and regulates interpersonal relationships

The importance of interpersonal relationships




Unless otherwise specified, all content on this website is original. If the reprinted content infringes on your rights, please contact the administrator to delete it
Contact Email:2380712278@qq.com

Filing number:皖ICP备19012824号