This function deletes a file.

Syntax: unlink(filename,context).

Description:

The first “Parameter” filename is Required. It Specifies the file to be deleted.

The second Parameter “context” is Optional. It Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream .

This function returns TRUE on success, or FALSE on failure.

Example:
Code:

$file  = "test.txt";
if (!unlink($file))
  {
  echo ("Error in the deleting $file");
  }
else
  {
  echo ("Deleted $file");
     }

Output:

Deleted test.txt

Explanation:

The above code will delete the test.txt file.

eXTReMe Tracker