PHP $_SERVER['REMOTE_ADDR'] empty

前端 未结 3 613
渐次进展
渐次进展 2020-12-11 04:09

Somehow $_SERVER[\'REMOTE_ADDR\'] returns an empty string, i have the same code (as part of a script) running on multiple servers and it works everywhere else,

3条回答
  •  醉梦人生
    2020-12-11 05:09

    Yes it's possible for REMOTE_ADDR to be empty. so if you want you can use this code that I use to get the ip based on HTTP_X_FORWARDED_FOR

    I'm checking REMOTE_ADDR first as it is more reliable and sometimes HTTP_X_FORWARDED_FOR can be spoofed by users

提交回复
热议问题