Is $_SERVER['REMOTE_ADDR'] always isset()?

后端 未结 3 1486
你的背包
你的背包 2020-12-20 12:23

I want to store ip2logn($_SERVER[\'REMOTE_ADDR\']) values in the db for some reason.

Practically, as I see, $_SERVER[\'REMOTE_ADDR\'] alwa

相关标签:
3条回答
  • 2020-12-20 13:10

    It will only be set if you're running the script through a webserver. If you're running PHP in CLI (command line) mode, REMOTE_ADDR will not be set, as there is no remote address for a command line script.

    0 讨论(0)
  • 2020-12-20 13:17

    $_SERVER['REMOTE_ADDR'] is always set even if you are working on localhost and can't be unset except you programmatically removed it And if you saved it in INT there would be no dots so you should save it as varchar

    0 讨论(0)
  • 2020-12-20 13:27

    $_SERVER vars are ALWAYS SET. Well, unless you have some odd php setup.

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