Click to See Complete Forum and Search --> : goto


mikerh9
12-06-2003, 04:33 PM
I look on the php.net page and coudn't find if PHP has goto ability. I need to use some sort for jump syntax in the code. IF something go to line 1 and and start execute code from line number....

For example
#code
goto line 1;

LordShryku
12-06-2003, 04:44 PM
Well, this really should be in the coding forum, not the code critique. Now, the best implementation of this would be to create a function. So instead of telling it goto line whatever, you just tell it to execute the function.

function doThis() {
echo "Blah";
}

if($whatever) {
doThis();
}

planetsim
12-06-2003, 05:29 PM
Actually creating a function is php version of goto to or gosub in basic (E.g. im talking more to QBasic as its the only basic language i know).

Weedpacket
12-06-2003, 09:55 PM
Urg. Goto. You know when that command was invented it was actually intended for exception handling?

Go To Statement Considered Harmful (http://www.acm.org/classics/oct95/)
Guiseppe Jacopini seems to have proved the (logical) superfluousness of the go to statement. The exercise to translate an arbitrary flow diagram more or less mechanically into a jump-less one, however, is not to be recommended. Then the resulting flow diagram cannot be expected to be more transparent than the original one.