当前位置:网站首页>PHP delete directory
PHP delete directory
2022-06-29 16:37:00 【If you get one】
Project scenario :PHP remove directory specified
public function deldir($dir) {
// Delete the files in the directory first :
if(is_dir($dir)){
$dh = opendir($dir);
while ($file = readdir($dh)) {
if($file != "." && $file!="..") {
$fullpath = $dir."/".$file;
if(!is_dir($fullpath)) {
// Determine the file creation time Delete after time
$file_size=filemtime($fullpath);
if($file_size<(time()-3600*24)){
@unlink($fullpath);
}
} else {
$this->deldir($fullpath);
}
}
}
closedir($dh);
// Delete the current folder :
if(@rmdir($dir)) {
return true;
} else {
return false;
}
}
}
// Get directory size This method is not used above, just leave a note
function dirsize($dir)
{
@$dh = opendir($dir);
$size = 0;
while ($file = @readdir($dh)) {
if ($file != "." and $file != "..") {
$path = $dir . "/" . $file;
if (is_dir($path)) {
$size += $this->dirsize($path);
} elseif (is_file($path)) {
$size += filesize($path);
}
}
}
@closedir($dh);
return $size;
}
Comments :
For personal summary , A rookie, a big guy, light spray , If you have any questions, you are welcome to testify , It would be great if it could help everyone ;
边栏推荐
- Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
- Science: the interrelated causes and consequences of sleep in the brain
- The third sprint of Wei long La Tiao: the growth rate of performance declined, and Liu Weiping and Liu Fuping cashed out in advance
- Huaxia Fund: sharing of digital transformation practice achievements in the fund industry
- Sophon KG升级3.1:打破数据间壁垒,解放企业生产力
- 技术分享| 融合调度中的广播功能设计
- 【Proteus仿真】数码管递加/递减带闪烁消隐显示
- MySQL error: expression 1 of order by claim is not in group by claim and contains nonaggregated column
- Time format GTM to Beijing time
- 加速智能驾驶项目落地?你还缺一套真值测评系统
猜你喜欢
Picture and text show you how to thoroughly understand the atomicity of MySQL transaction undolog
穩定幣風險狀况:USDT 和 USDC 安全嗎?
代码大全读后感
InheritableThreadLocal 在线程池中进行父子线程间消息传递出现消息丢失的解析
数学知识:求组合数 II—求组合数
关于XAMPP无法启动mysql数据库
After reading the complete code
The third sprint of Wei long La Tiao: the growth rate of performance declined, and Liu Weiping and Liu Fuping cashed out in advance
Sophon autocv: help AI industrial production and realize visual intelligent perception
Science: the interrelated causes and consequences of sleep in the brain
随机推荐
CompletableFuture的入门
Key sprite fighting monsters - multi window and multi thread background skills
Mysql database foundation: DDL data definition language
curl: (56) Recv failure: Connection reset by peer
为防止被00后整顿,一公司招聘要求员工不能起诉公司
工具链赋能百家,地平线开启智能驾驶量产的“马太效应”
MySQL foundation - multi table query
技术分享| 融合调度中的广播功能设计
2022年有哪些适合穷人的理财产品?
UWB precise positioning scheme, centimeter level high-precision technology application, intelligent pairing induction technology
Comment configurer logback? 30 minutes pour apprendre à coder et à frapper tard.
locust性能压测工具
[proteus simulation] 8-bit nixie tube dynamic scanning display change data
Selenium 凭什么成为 Web 自动化测试的首选?(内附源码)
C winfrom chart chart control bar chart and line chart
一个简单但是能上分的特征标准化方法
Sophon Base 3.1 推出MLOps功能,为企业AI能力运营插上翅膀
MySQL基础——多表查询
分片信息调哪个参数呢?用的是MySQLsource stream api,不是table api
Interviewer: tell me about the MySQL transaction isolation level?