When I started searching for "How to delete a file in PHP" The solution I got almost everywhere is "unlink()"
But in w3schools I met with another function named delete(). Here is that link delete() function w3schools
And I started surfing about delete() but didn't get much answers..
This is the question similar to my question at stackoverflow.. DIfferent between unlink() and delete() on unix
I really would like to know the difference and similarities between these two functions.. Why we are using unlink() instead of delete().
The unlink() function is used when you want to delete the files completely. The unset() Function is used when you want to make that file empty.
The unlink() function is an inbuilt function in PHP which is used to delete files. It is similar to UNIX unlink() function. The $filename is sent as a parameter that needs to be deleted and the function returns True on success and false on failure.
The unlink() function shall remove a link to a file. If path names a symbolic link, unlink() shall remove the symbolic link named by path and shall not affect any file or directory named by the contents of the symbolic link.
The unlink function deletes the file name filename . If this is a file's sole name, the file itself is also deleted. (Actually, if any process has the file open when this happens, deletion is postponed until all processes have closed the file.)
delete()
function doesn't exist as the php docs says
This is a dummy manual entry to satisfy those people who are looking for unlink() or unset() in the wrong place.
a dummy manual entry was created to catch anyone that is looking for a function that they assume to exist but doesn't really exist then guide them to the right function
http://php.net/manual/en/function.delete.php
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With