php实现删除空目录的方法

时间:2021-08-20 02:15:50

本文实例讲述了php实现删除空目录的方法。分享给大家供大家参考。具体分析如下:

php中可以通过rmdir()函数删除一个空目录

?
1
2
3
4
5
6
7
8
<?php
if (file_exists("/temp/test")) {
 rmdir("/temp/test");
 print("Directory removed.\n");
} else {
 print("Directory does not exist.\n");
}
?>

上面的代码第一次执行会返回

?
1
Directory removed.

第二次执行,由于目录已经被删除,会返回

?
1
Directory does not exist.

希望本文所述对大家的php程序设计有所帮助。