Copy code between infinite directories and directories_PHP tutorial

WBOY
Release: 2016-07-13 17:09:08
Original
1063 people have browsed it

Unlimited directory copy, original creation by the webmaster. Although it only took a few minutes to write, it is still quite useful

$o_path="admin";//Source directory
$n_path="n_admin";//New directory
class copy_path
{
function wm_chief_copypath($o_path,$n_path)
{$hand=opendir($o_path);
if(!file_exists($n_path))//If the target directory does not exist, create it
{$this->wm_chief_createpath($n_path);}
$i=0;
while($file=readdir($hand))
{$i ;
if($i==1||$i==2)
{continue;}
if(!(strchr($file,".")))
{
$o_s_path=$o_path."/".$file;
$n_s_path=$n_path."/".$file;
$this->wm_chief_copypath($o_s_path,$n_s_path);
}
else
{
$o_file=$o_path."/".$file;
$n_file=$n_path."/".$file;
$this->wm_chief_copyfile($o_file,$n_file);
}
}
closedir($hand);
return true;
}
function wm_chief_copyfile($o_file,$n_file)
{
copy($o_file,$n_file);
}
function wm_chief_createpath($n_path)
{
mkdir($n_path,0777);
}
}
$wm_chief=new copy_path();
$wm_chief_ok=$wm_chief->wm_chief_copypath($o_path,$n_path);
if($wm_chief_ok)
{
echo "Copy completed";
}

?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/629774.htmlTechArticleUnlimited directory copy, original creation by the webmaster. Although it only took a few minutes to write, it is still quite useful? $o_path=admin;//Source directory $n_path=n_admin;//New directory class copy_path { function wm_chi...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!