php文件删除实现方法
unlink() 函数删除文件。
若成功,则返回 true,失败则返回 false.
语法: unlink(filename,context)
参数 描述
filename 必需,规定要删除的文件.
context 可选,规定文件句柄的环境.Context 是可修改流的行为的一套选项.
<?php $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" ; } ?>下面加了判断文件是否存在:
<?php $myfile = "./test1.txt" ; if ( file_exists ( $myfile )) { $result =unlink ( $myfile ); echo $result ; } ?>file_exists() 函数检查文件或目录是否存在.
如果指定的文件或目录存在则返回 true,否则返回 false.
语法: file_exists(path)
查看更多关于php文件删除实现方法 - php文件操作的详细内容...
声明:本文来自网络,不代表【好得很程序员自学网】立场,转载请注明出处:http://www.haodehen.cn/did27855