PHP filter_input_array() လုပ်ဆောင်ချက်
ဥပမာ
POST variable သုံးခုကို စစ်ထုတ်ရန် filter_input_array() လုပ်ဆောင်ချက်ကို အသုံးပြုပါ။ လက်ခံရရှိသော POST ကိန်းရှင်များသည် အမည်၊ အသက်နှင့် အီးမေးလ်ဖြစ်သည်-
<?php
$filters = array (
"name" => array ("filter"=>FILTER_CALLBACK,
"flags"=>FILTER_FORCE_ARRAY,
"options"=>"ucwords"
),
"age" => array ( "filter"=>FILTER_VALIDATE_INT,
"options"=>array("min_range"=>1,"max_range"=>120)
),
"email" => FILTER_VALIDATE_EMAIL
);
print_r(filter_input_array(INPUT_POST, $filters));
?>
အထက်ဖော်ပြပါ ကုဒ်၏ အထွက်သည်-
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
filter_input_array() လုပ်ဆောင်ချက်သည် ပြင်ပ ကိန်းရှင်များ (ဥပမာ- ဖောင်ထည့်သွင်းမှုမှ) ရရှိပြီး ၎င်းတို့ကို ရွေးချယ်နိုင်သည် ။
ဤလုပ်ဆောင်ချက်သည် filter_input() ကိုအကြိမ်များစွာခေါ်ဆိုခြင်းအစား တန်ဖိုးများစွာကို ပြန်လည်ရယူခြင်း/စစ်ထုတ်ခြင်းအတွက် အသုံးဝင်သည်။
အထားအသို
filter_input_array(type, definition, add_empty)
ကန့်သတ်တန်ဖိုးများ
Parameter | Description |
---|---|
type | Required. The input type to check for. Can be one of the following:
|
definition | Optional. Specifies an array of filter arguments. A valid array key is a variable name, and a valid value is a filter name or ID, or an array specifying the filter, flags and options. This parameter can also be a single filter name/ID; then all values in the input array are filtered by the specified filter |
add_empty | Optional. A Boolean value. TRUE adds missing keys as NULL to the return value. Default value is TRUE |
နည်းပညာဆိုင်ရာအသေးစိတ်
ပြန်ပို့တန်ဖိုး- | အောင်မြင်မှုဆိုင်ရာ ကိန်းရှင်များ၏ တန်ဖိုးများပါရှိသော array တစ်ခု၊ ရှုံးနိမ့်မှုအပေါ် မှားသည်။ |
---|---|
PHP ဗားရှင်း- | 5.2+ |
PHP Changelog- | PHP 5.4 - add_empty ပါရာမီတာကို ထည့်ထားသည်။ |
❮ PHP Filter အကိုးအကားကို အပြီးသတ်ပါ။