As you might know, GOTO operator will be officially available in PHP 5.3


There is already a page in PHP Documentation about GOTO operator http://php.net/goto

The goto operator can be used to jump to another section in the program. The target point is specified by a label followed by a colon, and the instruction is given as goto followed by the desired target label.

I was following the discussion around GOTO back in 2006 when Sara Golemon introduce it in PHP6 branches; and personally I think that GOTO will provide solution for some specific programming needs that could be hardly written in object oriented or using if/swich cases, and much more easier with GOTOs.
Maybe because the first programming language I have learned is Basic when I was in primary school, and I remember that I have used GOTO here and there in that time. But I don’t think at all that goto as a PHP construct is a bad solution, and there is no need to compare it to Java/C++/Python or others. PHP became popular with a silly object oriented because it was simply making life easier for web developers.
And if you are wondering how to deal with GOTO here are some suggestions :
– First, you are not supposed to use Goto anywhere in your code.
– Secondly, Use Goto with moderation and only if you really need it.
– Finally, remember that it took THREE years to have this goto committed to PHP.
If I won’t need GOTO in my web pages or applications, I think this is something that I will definitely use while scripting in linux. Anyway, GOTO comments section and voice your opinion below.

4 COMMENTS

  1. I think its rather silly that a language as mature as php implements a GOTO statement at this time (5.3!).
    GOTO’s come from a era when we didn’t have the large set of control structures available we have right now. Worse, control structures were introduced in the first place, because GOTO’s became unmaintainable. I dont even see a object ori

  2. I think its rather silly that a language as mature as php implements a GOTO statement at this time (5.3!).
    GOTO’s come from a era when we didn’t have the large set of control structures available we have right now. Worse, control structures were introduced in the first place, because GOTO’s became unmaintainable. I dont even see a object ori

  3. I don’t understand why they would implement a GOTO operator in a modern programming language. If you use GOTO statements, your code turns into a bunch of overcooked spaghetti: impossible to maintain and very hard to follow while hunting for bugs.
    There is never a need for this operator. I’ve programmed a lot of (sometimes very complex) webapplications using PHP and I’ve never had the need for something like GOTO.
    I suspect the person who included this in PHP is someone with fond memories of Basic, who felt a bit nostalgic, possible had a little bit too much to drink, and hence made a bad decision.
    Throw it out in 5.4

  4. I don’t understand why they would implement a GOTO operator in a modern programming language. If you use GOTO statements, your code turns into a bunch of overcooked spaghetti: impossible to maintain and very hard to follow while hunting for bugs.
    There is never a need for this operator. I’ve programmed a lot of (sometimes very complex) webapplications using PHP and I’ve never had the need for something like GOTO.
    I suspect the person who included this in PHP is someone with fond memories of Basic, who felt a bit nostalgic, possible had a little bit too much to drink, and hence made a bad decision.
    Throw it out in 5.4

LEAVE A REPLY

Please enter your comment!
Please enter your name here