Jump to content


Photo

Labels in PHP


  • Please log in to reply
5 replies to this topic

#1 FIONEX

FIONEX
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 09 June 2006 - 07:52 PM

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.

#2 .josh

.josh
  • Staff Alumni
  • .josh
  • 14,871 posts

Posted 09 June 2006 - 07:56 PM

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.
Did I help you? Feeling generous? Buy me lunch! 
Please, take the time and do some research and find out how much it would have cost you to get your help from a decent paid-for source. A "roll-of-the-dice" freelancer will charge you $5-$15/hr. A decent entry level freelancer will charge you around $15-30/hr. A professional will charge you anywhere from $50-$100/hr. An agency will charge anywhere from $100-$250/hr. Think about all this when soliciting for help here. Think about how much money you are making from the work you are asking for help on. No, we do not expect you to pay for the help given here, but donating a few bucks is a fraction of the cost of what you would have paid, shows your appreciation, helps motivate people to keep offering help without the pricetag, and helps make this a higher quality free-help community :)

#3 kenrbnsn

kenrbnsn
  • Staff Alumni
  • Advanced Member
  • 8,235 posts
  • LocationHillsborough, NJ, USA

Posted 09 June 2006 - 08:02 PM

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

Ken

#4 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 09 June 2006 - 08:03 PM

I haven't used a goto statement since I first learnt Basic over 20 years ago, nor would I want to.
do {
    CODE
} while (A > B)

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#5 Fyorl

Fyorl
  • Members
  • PipPipPip
  • Advanced Member
  • 273 posts
  • LocationUK

Posted 09 June 2006 - 08:32 PM

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.
[table]



Don't worry, the printer fairies will sort it out.

#6 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 09 June 2006 - 08:53 PM

[!--quoteo(post=382042:date=Jun 9 2006, 09:32 PM:name=Fyorl)--][div class=\'quotetop\']QUOTE(Fyorl @ Jun 9 2006, 09:32 PM) View Post[/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

statement1
statement2
goto LABEL
function x()
     thought I'd define a function now
end function
LABEL:
Statement3

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users