Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between delete() and unlink() in PHP

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().

like image 331
Rakesh Avatar asked Aug 26 '14 05:08

Rakesh


People also ask

What is the difference between unset () and unlink () in PHP?

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.

What does the unlink () function do in PHP?

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.

What does unlink function do?

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.

Does unlink delete files?

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.)


1 Answers

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

like image 86
Netorica Avatar answered Oct 04 '22 01:10

Netorica