PHP unlink()函数 unlink()函数可以删除一个文件,并在成功时返回true,失败时返回false。 语法 bool unlink ( string filename [, resourcecontext ] )PHPCopy 这个函数可以删除一个文件名,类似于Unix C中的unlink()函数。 示例1 <?php file = "/PhpProject/php/sample.txt"; if(!unlink(file)) { echo ("Error deleting file"); } else { echo ("Deletedfile successfully"); } ?>PHPCopy 输出 Deleted /PhpProject/php/sample.txt successfullyPHPCopy 示例2 <?php fh = fopen("/PhpProject/test.html", "a"); fwrite(fh, "<h1> Hello world! </h1>"); fclose($fh); unlink("/PhpProject1/test.html"); ?>PHPCopy 输出 file deleted succcessfullyPHPCopy