Php Unset Function
# PHP unset() Function
[PHP Available Functions](#)
The **unset()** function is used to destroy the given variable.
PHP Version: PHP 4, PHP 5, PHP 7
### Syntax
void unset ( mixed $var [, mixed $... ] )
Parameter Explanation:
* $var: The variable to be destroyed.
### Return Value
No return value.
### Example
## Example
If you unset() a global variable inside a function, only the local variable is destroyed, and the variable in the calling environment will retain the same value it had before unset() was called.
## Example
The output will be:
bar
If you want to unset() a global variable inside a function, you can use the $GLOBALS array to achieve this:
## Example
If you unset() a variable passed by reference inside a function, only the local variable is destroyed, and the variable in the calling environment will retain the same value it had before unset() was called.
## Example
The above example will output:
something something
If you unset() a static variable inside a function, the static variable will be destroyed within the function. However, when the function is called again, the static variable will be restored to its value before it was destroyed.
## Example
The above example will output:
Before unset: 1, after unset: 23Before unset: 2, after unset: 23Before unset: 3, after unset: 23
[PHP Available Functions](#)
YouTip