(PHP 4, PHP 5)
unlink — 刪除文件
說明
bool unlink ( string$filename
[, resource $context
] )
刪除 filename
。和 Unix C 的
unlink() 函數(shù)相似。
發(fā)生錯(cuò)誤時(shí)會產(chǎn)生一個(gè) E_WARNING
級別的錯(cuò)誤。
參數(shù)
filename
文件的路徑。
context
Note: 在 PHP 5.0.0 中增加了對上下文(Context)的支持。有關(guān)上下文(Context)的說明參見 Streams。
返回值
成功時(shí)返回 TRUE
, 或者在失敗時(shí)返回 FALSE
。
更新日志
版本 說明 5.0.0 自 PHP 5.0.0 起 unlink() 也可以用于某些 URL 封裝協(xié)議。參考支持的協(xié)議和封裝協(xié)議 中的列表看哪些封裝協(xié)議支持 unlink()。
范例
Example #1 基本的 unlink() 用法
<?php
$fh = fopen('test.html', 'a');
fwrite($fh, '<h1>Hello world!</h1>');
fclose($fh);
unlink('test.html');
?>
參見
rmdir() - 刪除目錄