How can the unlink() function in PHP be used to specify a path for file deletion?

To use the unlink() function in PHP to specify a path for file deletion, you need to provide the full path to the file you want to delete. This is important because unlink() requires the full path to the file in order to delete it successfully. By specifying the full path, you ensure that the correct file is targeted for deletion.

$file_path = '/path/to/your/file.txt';
if (file_exists($file_path)) {
    unlink($file_path);
    echo 'File deleted successfully.';
} else {
    echo 'File does not exist.';
}