Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

4
  • Very brief. Accepted answer, also nice tips :)
    – MacMac
    Commented Jun 23, 2010 at 13:32
  • Also would you mind doing a brief about multiple ternary operators within one logical statement. This will be helpful to others. +1
    – RobertPitt
    Commented Jun 25, 2010 at 12:41
  • 1
    @RobertPitt: the brief advice would be: don't do it! Nested ternary operators quickly become unwieldy, unintelligible, unmaintainable code.
    – janmoesen
    Commented Jun 25, 2010 at 12:56
  • +1, and I cannot help but mention that X-Forwarded-For,like other headers, is completely spoofable. You could set $ip to 127.0.0.1 simply by saying so in your header. So this code would be open to "normal" bugs and "security" vulnerabilities.
    – janmoesen
    Commented Jun 25, 2010 at 12:58