note 111425 deleted from function.delete by googleguy
| From: | googleguy@php.net | Date: | Tue, 19 Feb 2013 07:54:18 +0000 |
| Subject: | note 111425 deleted from function.delete by googleguy | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-193680@lists.php.net to get a copy of this message | ||
Note Submitter: Yousef Ismaeil Cliprz
----
If you use this function you will get a error :
Fatal error: Call to undefined function delete();
so this not problem you can use unlink() function :
unlink();
Or create a new user function by using :
1 - function_exists();
2 - file_exists();
3 - unlink();
as in example you can use :
<?php
if (!function_exists('delete'))
{
/**
* Delete a file.
*
* @param (string) $filename - File name with path if exists.
* @author Yousef Ismaeil Cliprz.
*/
function delete($filename)
{
if (file_exists($filename))
{
return (bool) ((unlink($filename)) ? true : false);
}
else
{
return false;
}
}
}
// Use
if (delete('FileNameHere.php'))
{
echo 'File was deleted';
}
else
{
echo 'Some errors here ....';
}
?>