PHP删除文件

在PHP中, 我们可以使用unlink()函数删除任何文件。 unlink()函数仅接受一个参数:文件名。它类似于UNIX C unlink()函数。

如果未删除文件, PHP unlink()会生成E_WARNING级错误。如果成功删除文件, 则返回TRUE, 否则返回FALSE。

句法

bool unlink ( string $filename [, resource $context ] )

$ filename表示要删除的文件的名称。

PHP删除文件示例

<?php    
$status=unlink('data.txt');  
if($status){
echo "File deleted successfully";  
}else{
echo "Sorry!";  
}
?>

输出

File deleted successfully

来源:

https://www.srcmini02.com/29176.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_38033.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?