Isset Command in PHP
Let us have the following variable:
<?php
$test = null;
?>
Let's write a condition that checks
that the variable is not equal to null:
<?php
$test = null;
if ($test !== null) {
echo '+++';
} else {
echo '---';
}
?>
Such a check can be performed more conveniently
using a special command isset:
<?php
$test = null;
if (isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
You can perform the reverse check, that
the variable is not defined. To do this, we will perform
inversion of isset using the logical
NOT:
<?php
$test = null;
if (!isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Modify the following code according to the studied theory:
<?php
$test = null;
if ($test == null) {
echo '+++';
} else {
echo '---';
}
?>
Modify the following code according to the studied theory:
<?php
$test = null;
if ($test != null) {
echo '+++';
} else {
echo '---';
}
?>