This article mainly introduces PHP for file recursive operation method, interested in the friend's reference, I hope to be helpful to everyone.
Specific as follows:
<?php/* * Folder replication class */class Copyfile{public $fromFile;p ublic $toFile; */* $fromFile to copy who * $toFile copy to that */function Copyfil E ($fromFile, $toFile) { $this->createfolder ($toFile); $folder 1=opendir ($fromFile); while ($f 1=readdir ($folder 1)) { if ($f 1!= "." && $f 1!= ") { $path 2= "{$fromFile}/{$f 1}"; if (Is_file ($path 2)) { $file = $path 2; $newfile = "{$toFile}/{$f 1}"; Copy ($file, $newfile); } ElseIf (Is_dir ($path 2)) { $toFiles = $toFile. ' /'. $f 1; $this->copyfile ($path 2, $toFiles);}}} /* * Recursively Create folder */function CreateFolder ($dir, $mode = 0777) { if (Is_dir ($dir) | | @mkdir ($DIR, $mode)) { return true; } if (! $this->createfolder (dirname ($dir), $mode)) { return false;} Return @mkdir ($dir, $mode);}} Use the method//introduce this class, direct new CopyFile (' to copy who ', ' Copy to that '),//$file = new CopyFile (' aaaa/aaaaa ', ' bbbbb/bbbb ');? >
Summary : The above is the entire content of this article, I hope to be able to help you learn.
Related recommendations:
Php method for paging function based on SQLite
How PHP implements the Observer pattern
thinkphp implementation of bulk Delete column method