PHP'de isset Komutu
Şu değişkenimiz olduğunu varsayalım:
<?php
$test = null;
?>
Değişkenin null olmadığını kontrol eden
bir koşul yazalım:
<?php
$test = null;
if ($test !== null) {
echo '+++';
} else {
echo '---';
}
?>
Böyle bir kontrol, özel isset komutu
kullanılarak daha kolay yapılabilir:
<?php
$test = null;
if (isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Değişkenin tanımlanmadığı ters kontrol de
yapılabilir. Bunun için isset mantıksal
DEĞİL ile ters çevrilir:
<?php
$test = null;
if (!isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Aşağıdaki kodu öğrenilen teoriye göre değiştirin:
<?php
$test = null;
if ($test == null) {
echo '+++';
} else {
echo '---';
}
?>
Aşağıdaki kodu öğrenilen teoriye göre değiştirin:
<?php
$test = null;
if ($test != null) {
echo '+++';
} else {
echo '---';
}
?>