+ 6

What’s the difference between unset() and unlink() ?

9th Jun 2018, 6:20 PM
Anuska
Anuska - avatar
6 Answers
+ 6
* unset - Destroys a variable http://php.net/manual/en/function.unset.php * unlink - Deletes a file http://php.net/manual/en/function.unlink.php Hth, cmiiw
9th Jun 2018, 8:26 PM
Ipang
+ 5
Thanks Sachin Artani for details.
10th Jun 2018, 5:58 AM
Anuska
Anuska - avatar
+ 5
ThanksIpang .
10th Jun 2018, 5:59 AM
Anuska
Anuska - avatar
+ 4
Hi, unset() function is used to destroy a particular session variable. eg. unset($_SESSION['success']) unlink() function is used to remove the file from the file manager. I recently used it in a job portal, where a user when updates his CV, old CV will be replaced with new. So, to remove old one, I used unlink() function.
9th Jun 2018, 6:44 PM
Sachin Artani
Sachin Artani - avatar
+ 4
Anuska You're welcome : )
10th Jun 2018, 8:43 AM
Ipang
+ 3
unset sets defined variable to null and unlink just deletes file unlink(filename) unset($variablename)
10th Jun 2018, 8:20 PM
Mukul Mishra
Mukul Mishra - avatar