Home  >  Article  >  Backend Development  >  Simulate xcopy function_PHP tutorial

Simulate xcopy function_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 16:09:50946browse


Simulate xcopy function /***************************************
* System name: Function that simulates xcopy
* Program function: Simulate xcopy function
* Development date: 2003/03/14
****************************** ***********/
?>
//copy a direction's all files to another direction
function xCopy($source, $ destination, $child){
//Usage:
// xCopy("feiy","feiy2",1): Copy the files under feiy to feiy2, including subdirectories
// xCopy(" feiy","feiy2",0): Copy the files under feiy to feiy2, excluding subdirectories
//Parameter description:
// $source: source directory name
// $destination: destination Directory name
// $child: When copying, is it a subdirectory included?
if(!is_dir($source)){
echo("Error: the $source is not a direction!") ;
return 0;
}
if(!is_dir($destination)){
mkdir($destination,0777);
}


$handle =dir($source);
while($entry=$handle->read()) {
if(($entry!=".")&&($entry!="..") ){
if(is_dir($source."/".$entry)){
if($child)
xCopy($source."/".$entry,$destination."/" .$entry,$child);
}
else{

copy($source."/".$entry,$destination."/".$entry);
}

}
}

return 1;
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/314374.htmlTechArticleSimulate xcopy function?php /************************ ************************ * System name: function to simulate xcopy* Program function: function to simulate xcopy* Development date: 2003/03/14 ***** *******...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn