Jump to content

Archived

This topic is now archived and is closed to further replies.

FIONEX

Labels in PHP

Recommended Posts

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 HERE
If A > B Then GoTo RepeatCode

Does anyone know what I'm talking about?
If you do, is this possible in PHP kuz I'm in need of them.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
The way to do this type of coding
[code]
RepeatCode:
'CODE GOES HERE
If A > B Then GoTo RepeatCode
[/code]
without using a goto, would be with a "while" loop:
[code]<?php
while ($a > $b) {
//
//   code goes here
//
}
?>[/code]

Ken

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[!--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]statement1
statement2
goto LABEL
function x()
     thought I'd define a function now
end function
LABEL:
Statement3[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.