PHP filter_input(INPUT_SERVER, 'REQUEST_METHOD') returns null?

后端 未结 5 2251
一整个雨季
一整个雨季 2021-01-01 18:20

Why does this line return null in my live server?

filter_input(INPUT_SERVER, \'REQUEST_METHOD\');

The live server is p

5条回答
  •  无人及你
    2021-01-01 18:46

    I solve it changing my php.ini from:

    variables_order = "GPCS"
    

    To:

    variables_order = "GPCSE"
    

    By default PHP wasn't registering the environment variables, so this change enabled them. The interesting is that the INPUT_SERVER variables came back to work too!

    Just two addiotional informations, i am using PHP 7.0.13 and as said in other answers, this issue is related to a PHP bug.

    Another option is use the following:

    filter_var(getenv('REQUEST_METHOD'));
    

提交回复
热议问题