In the PHP script provided, what are some best practices for handling file deletion operations to avoid errors?

When handling file deletion operations in PHP, it is important to check if the file exists before attempting to delete it to avoid errors. Additionally, it is recommended to use the `unlink()` function to delete files as it is specifically designed for this purpose. Lastly, always handle potential errors that may occur during the deletion process to ensure a smooth execution of the script.

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

if (file_exists($file_path)) {
    if (unlink($file_path)) {
        echo 'File deleted successfully.';
    } else {
        echo 'Error deleting file.';
    }
} else {
    echo 'File does not exist.';
}