Jump to content

Labels in PHP


FIONEX

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.