In PHP, we can delete any file using unlink() function.
PHP unlink() generates E_WARNING level error if file is not deleted. It returns TRUE if file is deleted successfully otherwise FALSE.
Syntax:
bool unlink ( string $filename [, resource $context ] )
Unlink() function accepts only one argument.
$filename represents the name of the file to be deleted.
PHP Example to Delete file :
<?php
$status=unlink('file.txt');
if($status){
echo "File deleted successfully";
}else{
echo "Sorry! Something wrong in it";
}
?>
Output:---------------------
File deleted successfully
No comments:
Post a Comment