php通過遞歸方式復(fù)制目錄和子目錄的方法
更新時間:2015年03月13日 15:03:12 作者:work24
這篇文章主要介紹了php通過遞歸方式復(fù)制目錄和子目錄的方法,涉及php遞歸及目錄操作的技巧,具有一定參考借鑒價值,需要的朋友可以參考下
本文實(shí)例講述了php通過遞歸方式復(fù)制目錄和子目錄的方法。分享給大家供大家參考。具體實(shí)現(xiàn)方法如下:
<?php
function recurse_copy($src,$dst){
$dir = opendir($src);
@mkdir($dst);
while(false !== ( $file = readdir($dir)) ) {
if (( $file != '.' ) && ( $file != '..' )) {
if ( is_dir($src . '/' . $file) ) {
recurse_copy($src.'/'.$file,$dst.'/'.$file);
}
else {
copy($src.'/'.$file,$dst.'/'.$file);
}
}
}
closedir($dir);
}
?>
希望本文所述對大家的php程序設(shè)計(jì)有所幫助。
相關(guān)文章
Windows2003 下 MySQL 數(shù)據(jù)庫每天自動備份
Windows2003 下 MySQL 數(shù)據(jù)庫每天自動備份...2006-12-12
PHP基于curl模擬post提交json數(shù)據(jù)示例
這篇文章主要介紹了PHP基于curl模擬post提交json數(shù)據(jù)操作,結(jié)合實(shí)例形式分析了php使用curl實(shí)現(xiàn)post方式提交json數(shù)據(jù)相關(guān)操作步驟與注意事項(xiàng),代碼簡單實(shí)用,需要的朋友可以參考下2018-06-06
php checkdate、getdate等日期時間函數(shù)操作詳解
PHP的日期時間函數(shù)date()中介紹了PHP日期時間函數(shù)的簡單用法,這類將介紹更多的函數(shù)來豐富我們的應(yīng)用。2010-03-03
PHP圖像處理之使用imagecolorallocate()函數(shù)設(shè)置顏色例子
這篇文章主要介紹了PHP圖像處理之使用imagecolorallocate()函數(shù)設(shè)置顏色例子,本文給出了十進(jìn)制和十六進(jìn)制2種設(shè)置顏色的方法,需要的朋友可以參考下2014-11-11

