

What do you think of goto in php? - oscardelben

I am not a php programmer but when I heard that php would introduce goto's to the core I started to asking myself why anyone would ever think something like this, so what do you think of goto in php?
======
yan
In terms of 'goto' in general, I always apply this rule: Use your head.

'goto' isn't exactly elegant most of the time, but there are some cases where
it produces cleaner, yet still correct, code. If you understand it and its
repercussions, tread carefully.

------
russell
It's not worth adding. As others have said, there are useful cases where the
code is cleaner, but the potential for abuse is great. I dont know PHP, but if
it has break and continue (particularly with labels), then there is little use
for goto.

~~~
ErrantX
it does have break, yes (and I think continue though I confess I have never
used it :))

------
halo
There are corner cases where goto is more convenient than hacking around it
using higher-level constructs. It's not inherently evil. It's repeatedly been
shown that the developers of PHP regard it as a "kitchen sink" language where
every feature is thrown in in some form so adding goto makes sense in that
perspective.

------
noodle
i think its php's attempt to cater to the procedural programmers, which is
still a hefty chunk of its userbase.

don't use it.

