လက်ရှိတည်နေရာ: ပင်မစာမျက်နှာ> နောက်ဆုံးရဆောင်းပါးများစာရင်း> PHP တွင် variable ကိုအမျိုးအစားများထုတ်ပေးရန်အကောင်းဆုံးနည်းလမ်းများနှင့်ဥပမာများ

PHP တွင် variable ကိုအမျိုးအစားများထုတ်ပေးရန်အကောင်းဆုံးနည်းလမ်းများနှင့်ဥပမာများ

M66 2025-11-03

PHP အတွက် variable ကိုအမျိုးအစား output ကိုအမျိုးအစားများနည်း

PHP တွင်သင်သည် variable အမျိုးအစားကိုစစ်ဆေးလိုပါက GetType () function ကိုသုံးနိုင်သည်။ ၎င်းသည် variable အမျိုးအစားကိုကိုယ်စားပြုသည့် string ကိုပြန်ပို့သည်။

GetType () function နိဒါန်း

GetType () function ကိုမှပြန်လာသော string ကို Type တွင် -

  • Boolean: Boolean Value
  • Integer: Integer
  • နှစ်ဆ: floating အမှတ်နံပါတ်
  • string ကို: string ကို
  • Array: Array
  • အရာဝတ်ထု: အရာဝတ်ထု

နမူနာကုဒ်

 $x = 10;
$y = "Hello";
$z = true;

echo "Type of $x: " . gettype($x) . "<br>";
echo "Type of $y: " . gettype($y) . "<br>";
echo "Type of $z: " . gettype($z) . "<br>";

output ကိုရလဒ်များ

 Type of $x: integer
Type of $y: string
Type of $z: boolean

အကျဉ်းချုပ်

GetType () function ကိုအသုံးပြုခြင်းအားဖြင့်သင်သည် PHP တွင် variable များကိုအလွယ်တကူဆုံးဖြတ်ရန်နှင့်ထုတ်လွှင့်နိုင်သည်။ ၎င်းသည် debugging နှင့် data processing အတွက်အသုံးဝင်သည်။ ဤနည်းလမ်းကိုကျွမ်းကျင်ခြင်းသည်တီထွင်သူများသည် variable များနှင့် debug code ကိုပိုမိုထိရောက်စွာစီမံခန့်ခွဲနိုင်သည်။