Re: goto in php
From: DvDmanDT (dvdmandt_at_telia.com)
Date: 10/19/03
- Next message: baby baby: "excel or word and PHP/mysql"
- Previous message: Nikolai Chuvakhin: "Re: goto in php"
- In reply to: Runar Furenes: "goto in php"
- Next in thread: Michel: "Re: goto in php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: baby baby: "excel or word and PHP/mysql"
- Previous message: Nikolai Chuvakhin: "Re: goto in php"
- In reply to: Runar Furenes: "goto in php"
- Next in thread: Michel: "Re: goto in php"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|