search
Homephp教程php手册php文件删除实现方法

php文件删除实现方法

Jun 13, 2016 am 10:42 AM
falsephptrueunlinkfunctiondeletefailaccomplishsuccessdocumentmethodgrammarreturn

unlink() 函数删除文件。
若成功,则返回 true,失败则返回 false。
语法
unlink(filename,context)
参数 描述
filename 必需。规定要删除的文件。
context 可选。规定文件句柄的环境。Context 是可修改流的行为的一套选项。

 

   $file_delete = "home/meeta/my.php";
  
   if (unlink($file_delete)) {
      echo "The file was deleted successfully.", "n";
   } else {
      echo "The specified file could not be deleted. Please try again.", "n";
   }
?>下面加了判断文件是否存在

  $myfile = "./test1.txt";
  if (file_exists($myfile)) {
    $result=unlink ($myfile);
    echo $result;
  }
  ?>
file_exists() 函数检查文件或目录是否存在。
如果指定的文件或目录存在则返回 true,否则返回 false。
语法
file_exists(path)


 

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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.