Thursday 6 December 2012

Difference Between Unlink and Unset

unlink()

unlink() is a function for file system handling.
It will simply delete the file in context.  


Example for unlink() :

<?php
$fh = fopen('file.html', 'a');
fwrite($fh, 'Hello world!');
fclose($fh);
unlink('file.html');
?>

Unset ()

Unset () is used to destroy a variable in PHP. In can be used to remove a single variable, multiple variables, or an element from an array. It is phrased as Unset ($remove).
Also Known As: Unset Variable, Destroy Variable.

Example for unset() :

<?php
// remove a single variable
unset($a);

// remove a single element in an array
unset($my_array['element']);

// remove multiple variables
unset($a, $b, $c);
?> 

No comments:

Post a Comment