谁能解释一下,为什么我会收到非常奇怪的警告:
filter_input() expects parameter 1 to be long, string given
执行代码时,这是我的类的一部分,看起来非常好:
public static function Input($type, $data, $filter = 'FILTER_SANITIZE_SPECIAL_CHARS')
{
$type = 'INPUT_' . $type;
return filter_input($type, $data, $filter);
}
如果我将其更改为,例如:
return filter_input(INPUT_POST, $data, $filter);
然后警告将转到:
filter_input() expects parameter 3 to be long
.
如果我使用,一切都会正常工作:
return filter_input(INPUT_POST, $data, FILTER_SANITIZE_SPECIAL_CHARS);
我意识到PHP: filter_input - 手册 http://www.php.net/manual/en/function.filter-input.php描述中指出:
描述
mixed filter_input ( int $type , string $variable_name [, int $filter = FILTER_DEFAULT [, mixed $options ]] )
参数
type
One of INPUT_GET, INPUT_POST, INPUT_COOKIE, INPUT_SERVER, or INPUT_ENV.
问题:
- 为什么说明书上这么说
filter_input ( int $type ,
- 当两者都不是时输入获取 nor 输入_POST等等是INTEGERS.
- 有没有办法将值传递给
filter_input
使用变量?