What is the PHP function used to delete files?
To delete files in PHP, you can use the `unlink()` function. This function takes the file path as a parameter and removes the file from the server. It is important to ensure that the file exists and that the PHP script has the necessary permissions to delete the file.
$file_path = 'path/to/file.txt';
if (file_exists($file_path)) {
if (unlink($file_path)) {
echo 'File deleted successfully';
} else {
echo 'Unable to delete file';
}
} else {
echo 'File does not exist';
}