Pass a value into filter_input() using variable

前端 未结 3 1217
一向
一向 2021-01-21 23:24

Can anyone please explain, why do I get very strange warning:

filter_input() expects parameter 1 to be long, string given

when executing the co

3条回答
  •  没有蜡笔的小新
    2021-01-22 00:23

    What you're supposed to use there are constants. These constants have integer values. So the documentation is entirely correct, INPUT_GET is an integer. Try var_dump(INPUT_GET).

    If you need to get a constant value from a string, use constant():

    echo constant('INPUT_' . $type);
    

提交回复
热议问题