微信扫一扫打赏支持

PHP unlink() 函数(删除文件)

PHP unlink() 函数(删除文件)

一、总结

unlink() 函数删除文件。

1、实例

$file = "test.txt";
if (!unlink($file))

2、thinkphp项目中实例

if(file_exists($thumbpath)){
    @unlink($thumbpath);
}

 

 

二、PHP unlink() 函数(删除文件)

PHP unlink() 函数

定义和用法

unlink() 函数删除文件。

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

语法

unlink(filename,context)
参数描述
filename 必需。规定要删除的文件。
context 可选。规定文件句柄的环境。Context 是可修改流的行为的一套选项。

提示和注释

注释:对 context 的支持是 PHP 5.0.0 添加的。

例子

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

 

posted @ 2018-05-13 00:38  范仁义  阅读(440)  评论(0编辑  收藏  举报