gpt4 book ai didi

php - 如何向 filter_input 添加选项和标志

转载 作者:搜寻专家 更新时间:2023-10-31 20:41:57 25 4
gpt4 key购买 nike

如何向 filter_input 添加选项和标志? PHP 文档说要使用关联数组,但没有给出任何有关正确语法的示例。我尝试过各种格式,包括以下格式:

$textOpts = filter_input(INPUT_POST, "text", FILTER_SANITIZE_STRING, array("options" => FILTER_FORCE_ARRAY, "flags" => !FILTER_FLAG_ENCODE_LOW));
$textOpts = filter_input(INPUT_POST, "text", FILTER_SANITIZE_STRING, array("options" => array(FILTER_FORCE_ARRAY), "flags" => array(!FILTER_FLAG_ENCODE_LOW)));

我似乎无法理解语法,我该如何写这个?

最佳答案

<form name="test" id="test" action="" method="POST">
<input type="text" name="demo[]" id="demo[]" value="">
<input type="submit" name="submit-bt" id="submit-bt" value="Submit">
</form>
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);

$args = array('flags' => FILTER_REQUIRE_ARRAY,
'options' => array('min_range' => 1, 'max_range' => 10)
);

if (!empty($_POST['submit-bt'])){
$textOpts = filter_input(INPUT_POST, "demo", FILTER_VALIDATE_INT, $args);
print_R($textOpts);exit;
}

?>

关于php - 如何向 filter_input 添加选项和标志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20077404/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com