Home  >  Article  >  php教程  >  PHP如何删除文件或文件夹

PHP如何删除文件或文件夹

WBOY
WBOYOriginal
2016-06-13 09:38:06908browse

有时候我们需要用PHP来删除文件和文件夹,PHP本来也都有函数可以实现,下面简单记录一下代码,方便以后信守拈来。先看一下代码


unlink() 函数用于删除文件。若成功,则返回 true,失败则返回 false。rmdir() 函数用于删除空的目录。它尝试删除 dir 所指定的目录。 该目录必须是空的,而且要有相应的权限。

一个实例:删除某个文件夹下的所有".svn"文件夹(包括其内容也要被删除)。


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