Home  >  Article  >  Backend Development  >  PHP directory copy implementation method

PHP directory copy implementation method

WBOY
WBOYOriginal
2016-07-25 08:44:481051browse

The example in this article describes the implementation method of php directory copy. Share it with everyone for your reference. The details are as follows:

  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('e:/www/chat','e:/www/chat3');
Copy code

I hope this article will be helpful to everyone’s PHP programming design.

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