PHP unset
PHP unset is used to remove the value of a variable . After clearing, it will not return any results. In versions after 4.0.1, support for multiple parameters has been added. Simply use unset and just pass the variable to the unset function. , But it should be noted that if the variable you want to remove is the global variable in the function, then only the partial variable is removed.
PHP unset syntax example
void unset (variable to be removed)
PHP unset implementation example
$i=1;
echo'Original $i ='.$i.';';
unset($i);
echo'$i after executing unset ='.$i; // Output result: original $i = 1; $i =
?> after executing unset
unset result in function
function TestUnset() {
static $i;
$i=++; echo'before
execution $i ='.$i.';';
unset($i);
$i = 55;
echo'after execution$ i ='.$i.'<br>';
}
TestUnset(); // Output result: before execution $i = 1; after execution $i = 55
TestUnset(); // Output result: before execution $i = 2; after execution $i = 55
?>
For related instructions on global variables, please see the instructions on the official PHP website: PHP: unset-Manual .
Post a Comment
0 Comments