Re: goto in php

From: DvDmanDT (dvdmandt_at_telia.com)
Date: 10/19/03


Date: Sun, 19 Oct 2003 04:52:04 GMT

try

<?
do
{
//code to do, type "break;" to goto to the "while(0)" line
}while(0);
?>

You can also have nested do{}..while()'s... If you have while(0), it wont
loop, so unless you break, it does nothing at all... And if you break, you
just jump 'til the end...

example with nested do..while's:
<?
do{
do{
if($error=="FATAL")
break 2; // 'GOTO' [2]
do_some_things();
if($error=="WARNING")
break; // 'GOTO' [1]
echo "No errors yet!";
}while(0); // [1]
do_something_else_if_no_fatal_errors_have_occurred();
if($error=="RESTART")
continue; // Will 'goto' the first 'do'... Not sure about this,
//but I think that's the case...
}while(0); // [2]
?>

Notice that 'break n' will basicly count backwards, (not which one to jump
to, how many to get out of)...

-- 
// DvDmanDT
MSN: dvdmandt@hotmail.com
Mail: dvdmandt@telia.com
"Runar Furenes" <runar.remove@unvalidpart.do.no> skrev i meddelandet
news:3f912a78@news.broadpark.no...
> Is there a sentence similar to "goto" in php? I would like to have a
control
> sentence skipping some code if it's positive - "go-to" a lower part in the
> code. Thank you
> -- 
> Runar Furenes
> Norway


Relevant Pages

  • Re: How to do "continue" in VB?
    ... Other languages offer a way to jump from the middle ... > of a loop to continue with the next iteration. ... Goto will be fine, thanks!! ...
    (microsoft.public.vb.general.discussion)
  • Re: how do people feel about exit function from loop
    ... A for loop is very clear. ... exit conditions for the loop (assuming that someone isn't using an Exit ... Because goto can jump into loops and jump all over the place. ...
    (microsoft.public.vb.general.discussion)
  • Re: Why is GOTO bad?
    ... BREAK label or BREAK n is more flexible working with _ALL_ types of loop. ... "GOTO label"? ... With break label you can't accidentally jump inside ...
    (microsoft.public.vb.general.discussion)
  • RE: for next loop problems
    ... The recommended way to jump out of a for/next loop is to use the Exit For ... statement i.e instead of GoTo 178 use Exit For: ... Don't use absolute branching (GoTo 178): this style of coding is a nightmare ...
    (microsoft.public.excel.programming)
  • Re: Iteration in lisp
    ... state machine is just a tagbody and goto. ... But if you need to change the state-transition-matrix in the middle ... loop and either table-driven or separate-functions for defining the ... (tagbody state1 (trace-state1 aux) ...
    (comp.lang.lisp)