Blogger Information
Blog 51
fans 0
comment 1
visits 64955
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
PHP删除空文件夹
鱼的熊掌
Original
448 people have browsed it
  1. $path='./download/test'; //文件夹路径
  2. mkdir($path); //创建文件夹
  3. delFileUnderDir($path);
  4. mkdir($path); //删除空的文件夹
  5. //删除文件夹下的文件
  6. function delFileUnderDir( $dirName )
  7. {
  8. if ( $handle = opendir( "$dirName" ) ) {
  9. while ( false !== ( $item = readdir( $handle ) ) ) {
  10. if ( $item != "." && $item != ".." ) {
  11. if ( is_dir( "$dirName/$item" ) ) {
  12. delFileUnderDir( "$dirName/$item" );
  13. } else {
  14. if( unlink( "$dirName/$item" ) );
  15. }
  16. }
  17. }
  18. closedir( $handle );
  19. }
  20. }
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post