php 删除目录下N分钟前创建的所有文件_PHP教程

WBOY
Lepaskan: 2016-07-20 11:15:27
asal
777 orang telah melayarinya

<?<span php
</span><span /*</span><span *
* 删除当DIR路径下N分钟前创建的所有文件
* 整理:脚本学堂 www.jbxue.com
</span><span */</span>
<span //</span><span delfile("upload",10);</span>
<span function</span> delfile(<span $dir</span>,<span $n</span><span ) 
{
</span><span if</span>(<span is_dir</span>(<span $dir</span><span ))
{
</span><span if</span>(<span $dh</span>=<span opendir</span>(<span $dir</span><span ))
{
</span><span while</span> (<span false</span> !== (<span $file</span> = <span readdir</span>(<span $dh</span><span ))) 
{
</span><span if</span>(<span $file</span>!="." && <span $file</span>!=".."<span ) 
{
</span><span $fullpath</span>=<span $dir</span>."/".<span $file</span><span ;
</span><span if</span>(!<span is_dir</span>(<span $fullpath</span><span )) 
{ 
</span><span //</span><span $filedate=date("Y-m-d", filemtime($fullpath)); </span>
<span $filedate</span>=<span date</span>("Y-m-d h:i:s", <span filemtime</span>(<span $fullpath</span><span )); 
</span><span //</span><span $d1=strtotime(date("Y-m-d")); </span>
<span $d1</span>=<span strtotime</span>(<span date</span>("Y-m-d h:i:s"<span ));
</span><span $d2</span>=<span strtotime</span>(<span $filedate</span><span );
</span><span //</span><span $Days=round(($d1-$d2)/3600/24); </span>
<span $Days</span>=<span round</span>((<span $d1</span>-<span $d2</span>)/60<span ); 
</span><span if</span>(<span $Days</span>><span $n</span><span )
</span><span unlink</span>(<span $fullpath</span>); <span //</span><span //删除文件</span>
<span 
}
} 
}
}
</span><span closedir</span>(<span $dh</span><span ); 
}
}
</span>?>
Salin selepas log masuk

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/440200.htmlTechArticle? delfile( , ( ( ( = ( ( !== ( = ( ( !="." !=".." = ."/". (! ( = ("Y-m-d h:i:s", ( = ( ("Y-m-d h:i:s" = ( = (( - )/60 ( ( ); ( ?...
Label berkaitan:
sumber:php.cn
Kenyataan Laman Web ini
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Tutorial Popular
Lagi>
Muat turun terkini
Lagi>
kesan web
Kod sumber laman web
Bahan laman web
Templat hujung hadapan