PHP filter_input() လုပ်ဆောင်ချက်
ဥပမာ
ပြင်ပပြောင်းလဲနိုင်သော "အီးမေးလ်" ကို "get" နည်းလမ်းဖြင့် PHP စာမျက်နှာသို့ ပေးပို့ခြင်း ရှိ၊ မရှိ စစ်ဆေးပြီး ၎င်းသည် မှန်ကန်သော အီးမေးလ်လိပ်စာ ဟုတ်မဟုတ်ကိုလည်း စစ်ဆေးပါ-
<?php
if (!filter_input(INPUT_GET, "email", FILTER_VALIDATE_EMAIL)) {
echo("Email is not valid");
} else {
echo("Email is valid");
}
?>
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
filter_input() လုပ်ဆောင်ချက်သည် ပြင်ပပြောင်းလဲမှုတစ်ခု (ဥပမာ- ဖောင်ထည့်သွင်းမှုမှ) ရရှိပြီး ၎င်းကို ရွေးချယ်နိုင်သည် ။
အသုံးပြုသူထည့်သွင်းမှုကဲ့သို့သော မလုံခြုံသောရင်းမြစ်များမှ ကိန်းရှင်များကို အတည်ပြုရန်အတွက် ဤလုပ်ဆောင်ချက်ကို အသုံးပြုပါသည်။
အထားအသို
filter_input(type, variable, filter, options)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
type | Required. The input type to check for. Can be one of the following:
|
variable | Required. The variable name to check |
filter | Optional. Specifies the ID or name of the filter to use. Default is FILTER_DEFAULT, which results in no filtering |
options | Optional. Specifies one or more flags/options to use. Check each filter for possible options and flags |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | ကိန်းရှင်အား မသတ်မှတ်ပါက အောင်မြင်မှုဆိုင်ရာ ကိန်းရှင်၏တန်ဖိုး၊ ရှုံးနိမ့်မှုတွင် မှားနေသည် သို့မဟုတ် NULL |
---|---|
PHP ဗားရှင်း- | 5.2+ |
❮ PHP Filter အကိုးအကားကို အပြီးသတ်ပါ။