Skip to main content
edited tags
Link
Mark Amery
  • 158.3k
  • 93
  • 435
  • 476
Added PHP tag, given the use of `$_SERVER` in the question
Link
Mawg
  • 40.5k
  • 110
  • 334
  • 582
Post Reopened by Joe Albahari, Nikhil, Mehul Mistri, krock, Graviton
Question Protected by Alix Axel
Post Closed as "off topic" by Gilles
Source Link
Gilles
  • 7.4k
  • 3
  • 24
  • 24

Maximum length of the textual representation of an IPv6 address?

I want to store the data returned by $_SERVER["REMOTE_ADDR"] in PHP into a DB field, pretty simple task, really. The problem is that I can't find any proper information about the maximum length of the textual representation of an IPv6 address, which is what a webserver provides through $_SERVER["REMOTE_ADDR"].

I'm not interested in converting the textual representation into the 128 bits the address is usually encoded in, I just want to know how many characters maximum are needed to store any IPv6 address returned by $_SERVER["REMOTE_ADDR"].