3 ms·
What do you think of goto in php?
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 18y agoIn 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.
- halo 18y agoThere 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 18y agoi think its php's attempt to cater to the procedural programmers, which is still a hefty chunk of its userbase. don't use it.
- russell 18y agoIt'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 18y agoit does have break, yes (and I think continue though I confess I have never used it :))