PHP Delete File

To delete a file in PHP, unlink() function is used. PHP unlink() function behaves same as UNIX C unlink() function. If the file is deleted successfully, it generates a TRUE value. If the file is not deleted successfully it generates a FALSE value or returns an E_WARNING level error.


bool unlink ( string $filename, context )

Filename:  This is a mandatory parameter which specifies the name of the file to be deleted.

Context:   This is an optional parameter which specifies the context (set of options to modify a stream’s behaviour ) of the file handle.


<!DOCTYPE html>
echo "File deleted.";    
echo "Unable to Delete the File.";    


File deleted.
Content Protection by
Please Share