Afficher un message
Vieux 15/02/2008, 08h49   #10
Robert K S
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Is there any sort of preprocessor functionality in PHP4?

On Feb 14, 10:12pm, Norman Peelman <npeel...@cfl.rr.com> wrote:
> Robert K S wrote:
> > Setup: I have a big tree of "if" statements (imagine the PHP code
> > version of a choose-your-own-adventure story) and I want to be able to
> > tell which end-branch I've reached. Right now, l have all the end-
> > branches numbered with integers, and the integer of the end branch is
> > returned.

>
> > Problem: If I insert a new end-branch, I have to laboriously re-number
> > all the end branches that come after it. As the tree gets larger and
> > larger, this becomes more and more of a hassle.

>
> > This has me wondering if PHP has any functionality that would allow me
> > to have the engine auto-insert the numbering for me on a pass of the
> > script that would occur prior to execution. That way I could make the
> > script just have some sort of ++ deal at each end branch, rather than
> > assigning the numbers in the script by hard-coding them in.

>
> > Alternatively, is there some other way to accomplish the same thing?

>
> > Thanks!

>
> > Robert K S

>
> How about using the magic constant __LINE__ as the return value. It
> returns the line number of the line it is used in. So you will always
> get the same number on successive runs and when you insert a new end
> branch it will update automagically.
>
> --
> Norman
> Registered Linux user #461062- Hide quoted text -
>
> - Show quoted text -


Jerry and Norman--perfect. That'll do the trick nicely. Thanks,
guys.

Robert
  Réponse avec citation
 
Page generated in 0,05578 seconds with 9 queries