What are some PHP functions that can be used to delete files outside of the /var/www directory?

When deleting files outside of the /var/www directory in PHP, it is important to be cautious as it can pose security risks. One way to safely delete files outside of the web root directory is to use the `unlink()` function along with appropriate file path validation to ensure that only allowed files are deleted.

$directory = '/path/to/allowed/directory/';
$file = $directory . 'file_to_delete.txt';

if (strpos(realpath($file), realpath($directory)) !== 0) {
    // File is not within allowed directory
    die('Access denied');
}

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