PHP-də isset komandası
Tutaq ki, bizim aşağıdakı dəyişənimiz var:
<?php
$test = null;
?>
Gəlin dəyişənin null olmadığını yoxlayan
şərt yazaq:
<?php
$test = null;
if ($test !== null) {
echo '+++';
} else {
echo '---';
}
?>
Belə bir yoxlamanı xüsusi isset komandası
ilə daha rahat yerinə yetirmək olar:
<?php
$test = null;
if (isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Dəyişənin təyin olunmadığını yoxlamaq da olar.
Bunun üçün məntiqi NOT ilə isset
şərtini inverasiya edək:
<?php
$test = null;
if (!isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Aşağıdakı kodu öyrənilən teoriyaya əsasən dəyişin:
<?php
$test = null;
if ($test == null) {
echo '+++';
} else {
echo '---';
}
?>
Aşağıdakı kodu öyrənilən teoriyaya əsasən dəyişin:
<?php
$test = null;
if ($test != null) {
echo '+++';
} else {
echo '---';
}
?>