5

The only correct way to use a GOTO.

Comments
  • 8
    it's php, that goto is probably the most sane line in the codebase.
  • 3
    Goto can be useful but there are almost always a better way or at least another way.

    Jumping to another case in a switch is one way but you could solve that with a recursive function around the switch if you want.

    The problem with goto is that its very easy to break things.

    But in some cases, when performance is paramount a goto can be way faster than any alternative or the alternative can actually be more complex but thats a definite odd case.

    If any alternative solution is either much slower or very much more difficult to follow a goto might be the best option, but make sure the label is very descriptive so its easy to see why its there.
  • 2
    Like someone is purposely writing bad code. How about the security breach of the previous line??

    Imagine someone sending a POST with a key named 'functionname' and a value of 'die'

    ( $_POST['functionname'] = 'die' )
Add Comment