PHP's filter_input() strips $_SERVER data on external host, but works on localhost

前端 未结 2 1877
傲寒
傲寒 2021-01-13 20:44

I am running an apache2 server where I do my localhost testing (PHP 5.5), but my hosting provider has PHP 5.3. I don\'t know whether that is an issue, but I mention it just

相关标签:
2条回答
  • 2021-01-13 21:10

    I had the same problem, I won't be able to tell you why it returns an empty string/FALSE but for me using INPUT_ENV instead of INPUT_SERVER did work and returns the same IP-address as $_SERVER['REMOTE_ADDR']. Same goes for HTTP_USER_AGENT. Short example:

    $REMOTE_ADDR = filter_input(INPUT_ENV, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
    
    0 讨论(0)
  • 2021-01-13 21:26

    My guess would be something related to this bug: https://github.com/wp-stream/stream/issues/254

    Try to use the bugfix on your code as a workaround

    0 讨论(0)
提交回复
热议问题