note 65523 deleted from function.delete by bjori
| From: | bjori@php.net | Date: | Tue, 02 May 2006 18:51:13 +0000 |
| Subject: | note 65523 deleted from function.delete by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-110384@lists.php.net to get a copy of this message | ||
Note Submitter: mikolaj73 at hotmail dot com
Reason: useless
----
function delete ($file, $ext) { //provide name and extension
if (file_exists($file.'.'.$ext)) { //checking if the file exists
unlink($file.'.'.$ext); } //delete the file
else echo "File <b>$file</b> not found"; //print out the error
}
//usage of the function delete
//You dont have to check if the file you want to delete exists,
//its automatically done within the function
$something = 1
if ($something == 1) delete ('somefile', 'php');
else exit($something.' is false');
/*comments : the $ext variable is not needed, but it's useful when you are dealing with a lot
of different extensions, for example:*/
$php = 'php'; //NO dots!!
$html = 'html';
if ($something == 1) delete ('somefile', $php);
else delete ('someotherfile', $html);