Home >Backend Development >PHP Tutorial >Copy directories and subdirectories recursively in php

Copy directories and subdirectories recursively in php

WBOY
WBOYOriginal
2016-07-25 08:43:331089browse
  1. function recurse_copy($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. recurse_copy($src . '/' . $file,$dst . '/' . $file);
  8. }
  9. else {
  10. copy($src . '/' . $file,$dst . '/' . $file);
  11. }
  12. }
  13. }
  14. closedir($dir);
  15. }
  16. ?>
复制代码

php


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