Home Menu

unset

Unset a given variable

Syntax

unset ( mixed $var [, mixed $... ] ) : void

Parameters

var

The variable to be unset.

...

Another variable ...

Return

No value is returned.

Examples

1

<?

$var = 1;

unset($var);

var_dump($var);

?>
NULL

2

<?

$var1 = 1;
$var2 = 2;
$var3 = 3;

unset($var1, $var2, $var3);

var_dump($var1, $var2, $var3);

?>
NULL
NULL
NULL

3

<?

$var = array(0, 1, 2);

unset($var);

var_dump($var);

?>
NULL

4

<?

$var = array(0, 1, 2);

unset($var[1]);

print_r($var);

?>
Array
(
    [0] => 0
    [2] => 2
)

5

<?

$var = array("a" => 0, "b" => 1, "c" => 2);

unset($var["b"]);

print_r($var);

?>
Array
(
    [a] => 0
    [c] => 2
)

PHP

JesusBible
HTMLCSSJSPHPSVGMore
AboutTerms