Example 1 — Removing a Variable
Create a variable, check it with isset(), remove it with unset() and check it again.
<?php
$name = 'Asha';
echo isset($name) ? 'set' : 'not set', PHP_EOL;
unset($name);
echo isset($name) ? 'set' : 'not set', PHP_EOL; How It Works
- $name is created with a value. isset() finds it and the first line prints set.
- unset($name) destroys the variable. It no longer exists after this line.
- isset() now returns false. The second line prints not set.
- No warning is shown. isset() is safe to use on a variable that does not exist.

