Copy code between an infinite directory and a directory _php tutorial

Source: Internet
Author: User
Unlimited directory replication, stationmaster original, although only wrote a few minutes, but still very 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))//target directory does not exist then establish
{$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 Complete";
}

?>

http://www.bkjia.com/PHPjc/629774.html www.bkjia.com true http://www.bkjia.com/PHPjc/629774.html techarticle Unlimited directory replication, stationmaster original, although only wrote a few minutes, but still very useful? $o _path=admin;//Source directory $n _path=n_admin;//new directory class Copy_path {function Wm_chi ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.