PHP deletes a directory and all subordinate directories and file codes within the directory

WBOY
Release: 2016-07-25 08:42:20
Original
708 people have browsed it
  1. //PHP deletes the directory and all subordinate directories and file codes in the directory
  2. function delDir( $dirName='' ){
  3. if ( $handle = opendir( "$dirName" ) ) {
  4. while ( false ! == ( $item = readdir( $handle ) ) ) {
  5. if ( $item != "." && $item != ".." ) {
  6. if ( is_dir( "$dirName/$item" ) ) {
  7. $this->delDir( "$dirName/$item" );
  8. } else {
  9. unlink( "$dirName/$item" );
  10. }
  11. }
  12. }
  13. closedir( $handle );
  14. }
  15. }
  16. delDir('directory');
Copy code

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