Home > Backend Development > PHP Tutorial > How to delete empty directories in php_PHP tutorial

How to delete empty directories in php_PHP tutorial

WBOY
Release: 2016-07-13 10:03:22
Original
960 people have browsed it

How to delete empty directories in php

This article mainly introduces the method of deleting empty directories in php. It analyzes the usage skills of rmdir function with examples, which has certain reference value. , friends in need can refer to it

The example in this article describes how to delete empty directories in PHP. Share it with everyone for your reference. The specific analysis is as follows:

You can delete an empty directory through the rmdir() function in php

?

1

2

3

4

5

6

7

8

if (file_exists("/temp/test")) {

rmdir("/temp/test");

print("Directory removed.n");

} else {

print("Directory does not exist.n");

}

?>

1 2

3

4

5

6

1

Directory removed.

7 8

if (file_exists("/temp/test")) {

rmdir("/temp/test");

1

Directory does not exist.

print("Directory removed.n");

} else {

print("Directory does not exist.n");

}

?>

The above code will return when executed for the first time ?
1 Directory removed.
The second execution will return because the directory has been deleted. ?
1 Directory does not exist.
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/968670.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/968670.htmlTechArticleHow to delete empty directories in php. This article mainly introduces the method of deleting empty directories in php and analyzes it with examples. The usage skills of rmdir function have certain reference value. Friends who need it...
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