Deprecated: The each() function is deprecated. This message will be suppressed on further calls in /home/zhenxiangba/zhenxiangba.com/public_html/phproxy-improved-master/index.php on line 456
PHP: delete - Manual
[go: Go Back, main page]

PHP
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

dirname" width="11" height="7"/> <copy
Last updated: Sun, 25 Nov 2007

view this page in

delete

(PECL zip:1.1.0-1.4.1)

delete — unlink()unset() を参照してください

説明

void delete ( void )

この関数はダミーの関数エントリであり、間違った場所で unlink() または unset() を要求する人の要求を満足させるためのものです。

返り値

値を返しません。

参考

  • ファイルを削除するには unlink()
  • 変数を削除するには unset()



dirname" width="11" height="7"/> <copy
Last updated: Sun, 25 Nov 2007
 
add a note add a note User Contributed Notes
delete
RisingKing
14-Feb-2008 09:41
<?
$filename
=stripslashes($_GET['file']);
if(
file_exists("$filename"))
{
if(
unlink("$filename"))
{
echo
"File was successfully deleted";
}
else
{
echo
"File was not deleted.";
}
}
else
{
echo
"File does not exist.";
}
?>

This checks if the file exists, if the file exists it deletes the file and returns a message confirming the deletion. If the file was not deleted, a message will be returned say the file was not deleted. If the file does not exist, a message will be returned say the file doesn't exist.
To use the script just add at the end of the URL ?file={the file you want to delete}
Ex:
127.0.0.1/delete.php?file=New Text Document.txt
That will delete the file New Text Document.txt
Guilherme Komel
30-Dec-2007 09:14
I have founda that trying to delete a file using relative path like the example below does not work.

    $do = unlink("../pics/$fileToDel");
    if($do=="1"){
        echo "The file was deleted successfully.";
    } else { echo "There was an error trying to delete the file."; }

I did not work at all, instead what I had to do was:

    chdir('../pics/');
    $do = unlink($fileToDel);
    if($do=="1"){
        echo "The file was deleted successfully.";
    } else { echo "There was an error trying to delete the file."; }

Then it worked !
bmcouto at hotmail dot com
01-Oct-2006 05:30
$myFile = "testFile.txt";
$fh = fopen($myFile, 'w') or die("can't open file");
fclose($fh);

Now to delete testFile.txt we simply run a PHP script that is located in the same directory. Unlink just needs to know the name of the file to start working its destructive magic.

$myFile = "testFile.txt";
unlink($myFile);

The testFile.txt should now be removed.

dirname" width="11" height="7"/> <copy
Last updated: Sun, 25 Nov 2007
 
 
show source | credits | sitemap | contact | advertising | mirror sites