What are some common mistakes or misunderstandings when implementing file deletion functionality in PHP scripts?

One common mistake when implementing file deletion functionality in PHP scripts is not checking if the file exists before attempting to delete it. This can result in errors or security vulnerabilities if the file being deleted does not exist. To solve this issue, always use the `file_exists()` function to check if the file exists before attempting to delete it.

$file_path = '/path/to/file.txt';

if (file_exists($file_path)) {
    unlink($file_path);
    echo "File deleted successfully.";
} else {
    echo "File does not exist.";
}