首頁  >  文章  >  後端開發  >  能否將PHP的filter_input()過濾器標誌與AND/OR結合使用?

能否將PHP的filter_input()過濾器標誌與AND/OR結合使用?

WBOY
WBOY轉載
2023-09-04 15:01:08548瀏覽

能否將PHP的filter_input()過濾器標誌與AND/OR結合使用?

是的,可以在 PHP 中將 filter_input() 與 AND/OR 結合。這可以透過循環 POST 欄位來完成 -

$value = filter_input(INPUT_POST, 'field', FILTER_DEFAULT, is_array($_POST['field']) ? FILTER_REQUIRE_ARRAY : NULL);

每個循環的相同使用者的等效項如下所示 -

$memory = array();
//looping through all posted values
foreach($_POST as $key => $value) {
   //applying a filter for the array
   if(is_array($value)) {
      $ memory [$key] = filter_input(INPUT_POST, $key, {filters for array});
   }
   else {
      $ memory [$key] = filter_input(INPUT_POST, $key, {filters for scalar});
   }
}

以上是能否將PHP的filter_input()過濾器標誌與AND/OR結合使用?的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:tutorialspoint.com。如有侵權,請聯絡admin@php.cn刪除