PHP တွင် isset ကွန်မန်
အောက်ပါ variable ရှိတယ်ဆိုပါစို့။
<?php
$test = null;
?>
Variable က null မဟုတ်ကြောင်း စစ်ဆေးတဲ့ condition တစ်ခု ရေးကြည့်ရအောင်။
<?php
$test = null;
if ($test !== null) {
echo '+++';
} else {
echo '---';
}
?>
ဒီလိုစစ်ဆေးမှုကို အထူး command isset ကို သုံးပြီး ပိုအဆင်ပြေအောင် လုပ်နိုင်ပါတယ်။
<?php
$test = null;
if (isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
Variable က သတ်မှတ်ထားခြင်း မရှိကြောင်း ပြောင်းပြန်စစ်ဆေးနိုင်ပါတယ်။
ဒီအတွက် boolean NOT ကို သုံးပြီး isset ကို ပြောင်းပြန်လှန်နိုင်ပါတယ်။
<?php
$test = null;
if (!isset($test)) {
echo '+++';
} else {
echo '---';
}
?>
အောက်ပါကုဒ်ကို လေ့လာထားတဲ့ သီအိုရီအတိုင်း ပြင်ဆင်ပါ။
<?php
$test = null;
if ($test == null) {
echo '+++';
} else {
echo '---';
}
?>
အောက်ပါကုဒ်ကို လေ့လာထားတဲ့ သီအိုရီအတိုင်း ပြင်ဆင်ပါ။
<?php
$test = null;
if ($test != null) {
echo '+++';
} else {
echo '---';
}
?>