php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48669 PHP now includes GOTO
Submitted: 2009-06-23 23:46 UTC Modified: 2010-10-20 11:20 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
From: iwannalive at hotmail dot com Assigned:
Status: Not a bug Package: Reproducible crash
PHP Version: 5.3.0RC4 OS: All
Private report: No CVE-ID: None
 [2009-06-23 23:46 UTC] iwannalive at hotmail dot com
Description:
------------
PHP 5.3 includes goto. This is a problem. Seriously, PHP has made it this far without goto, why turn the language into a public menace?

Reproduce code:
---------------
<?php
goto a;
echo 'Foo';
 
a:
echo 'Bar';
?>


Expected result:
----------------
The world will end.

Actual result:
--------------
The world ended.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-06-23 23:56 UTC] derick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

.
 [2009-08-04 18:47 UTC] andrei@php.net
goto hell;
 [2010-05-07 14:41 UTC] anil at ozselgin dot com
It makes php more buggy and suitable only for small programs. Is there anybody out there like readable code.
 [2010-07-14 01:02 UTC] risto78 at gmail dot com
sounds like a valid bug to me ;)
 [2010-10-08 20:30 UTC] thehazard at gmail dot com
Seriously, goto is awesome and in some cases, 
very useful and can make the code a lot more clean.

Are bad/unexperienced programmers use 'goto' to create some crazy ugly mess?

I have no doubt about it, but that doesn't mean that the feature 
itself is the problem. The problem is the programmer's inexperience,
and it is not the place of the language to teach the programmer
better programming practices.

Goto is great, for example, for cleanups. You put some cleanup 
code in the end of a function and in its body you check for 
several test cases where things could go wrong. If something goes
wrong, you signal the error and jump directly to the cleanup 
with 'goto', instead of having to create a big mess of if's to 
test if an error has happened or not on each step, to then decide
whether your function should continue executing or not. 
It is a primitive in pretty much any architecture 
(cmp, jmp/jz, etc) and used extensively in the linux kernel,
for example.

Anyone who complains about goto being 'dangerous' is either 
a blind fad follower or just believes that the language should
master the programmer (and not the other way around).
 [2010-10-19 07:18 UTC] phpbugs at ordisante dot com
Why would you need GOTO for bug handling? We have a wonderful Exception system.  
It can do everything you want.
 [2010-10-20 08:47 UTC] riaanvermaak at gmail dot com
I don't see anything wrong with using "goto" the php manual says:
"...The target label must be within the same file and context..."

Surely if a programmer manages to mess up the use of this, he/she must be a complete nit·wit...

I can't recommend anyone to mess up their code with a million goto's but, it may be useful.

if you don't want to take on the task of determining how, when and when not, to make use of certain aspects of a language, it really is your own loss...

You are then, beyond help.
 [2010-10-20 11:20 UTC] aharvey@php.net
-Block user comment: N +Block user comment: Y
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 14:01:30 2024 UTC