PHP realizes the copy function of the entire directory

WBOY
Release: 2016-07-25 08:45:31
Original
1082 people have browsed it
  1. function copy_dir($src,$dst) {
  2. $dir = opendir($src);
  3. @mkdir($dst);
  4. while(false !== ( $file = readdir($dir)) ) {
  5. if (( $file != '.' ) && ( $file != '..' )) {
  6. if ( is_dir($src . '/' . $file) ) {
  7. copy_dir($src . '/' . $file,$dst . '/' . $file);
  8. continue;
  9. }
  10. else {
  11. copy($src . '/' . $file,$dst . '/' . $file);
  12. }
  13. }
  14. }
  15. closedir($dir);
  16. }
  17. copy_dir('目录1','目录2');
复制代码

PHP


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!