FIONEX Posted June 9, 2006 Share Posted June 9, 2006 Hey, I was wondering if PHP supports labels, but I doubt they're called labels because I've searched and couldn't find anything.Labels in VB or other languages for that matter look like this:RepeatCode:'CODE GOES HEREIf A > B Then GoTo RepeatCodeDoes anyone know what I'm talking about?If you do, is this possible in PHP kuz I'm in need of them. Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/ Share on other sites More sharing options...
.josh Posted June 9, 2006 Share Posted June 9, 2006 no. and you don't need them, either. if you post your current code and what you are trying to do, then we can show you how to do it. edit: mostly what replaces any kind of useful feature of labels is functions and objects. Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/#findComment-43813 Share on other sites More sharing options...
kenrbnsn Posted June 9, 2006 Share Posted June 9, 2006 The way to do this type of coding[code]RepeatCode:'CODE GOES HEREIf A > B Then GoTo RepeatCode[/code]without using a goto, would be with a "while" loop:[code]<?phpwhile ($a > $b) {//// code goes here //}?>[/code]Ken Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/#findComment-43815 Share on other sites More sharing options...
Barand Posted June 9, 2006 Share Posted June 9, 2006 I haven't used a goto statement since I first learnt Basic over 20 years ago, nor would I want to.[code]do { CODE} while (A > B)[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/#findComment-43817 Share on other sites More sharing options...
Fyorl Posted June 9, 2006 Share Posted June 9, 2006 It's only really needed for linear code. If you do a few tutorials on this site you'll see that even linear code isn't actually linear. Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/#findComment-43826 Share on other sites More sharing options...
Barand Posted June 9, 2006 Share Posted June 9, 2006 [!--quoteo(post=382042:date=Jun 9 2006, 09:32 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 09:32 PM) [snapback]382042[/snapback][/div][div class=\'quotemain\'][!--quotec--]It's only really needed for linear code. If you do a few tutorials on this site you'll see that even linear code isn't actually linear.[/quote]It isn't *needed* at all. Plus I've seen it abused too many times, even in commercial packages.Such as - leaping out of for() loops to some other part of the program - and even[code]statement1statement2goto LABELfunction x() thought I'd define a function nowend functionLABEL:Statement3[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11609-labels-in-php/#findComment-43840 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.