Home  >  Article  >  php教程  >  php unlink函数 删除一个文件程序代码

php unlink函数 删除一个文件程序代码

WBOY
WBOYOriginal
2016-06-13 10:16:271133browse

在php中我们要删除一个指定的文件我们可以使用unlink函数来实现,下面我给大家详细介绍unlink函数删除一个指定文件的具体方法,有需要了解的朋友可参考参考。

unlink() 函数删除文件。

若成功,则返回 true,失败则返回 false。

 代码如下 复制代码

unlink("test.txt");
?>

 代码如下 复制代码

$file = "test.txt";if (!unlink($file))  {
 echo ("Error deleting $file");  }else  { 
echo ("Deleted $file");  }
?>

加上判断

 代码如下 复制代码

$file = "test.txt";
if(unlink($file))
{
  echo "文件 $file 删除成功!";
}
else
{
  echo "文件 $file 删除失败!";
}
?>

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