Like I said, where you define your function is important, not where you
call it. If you are defining and calling it all in the same place, then
yes, obviously it makes a difference.
-Rasmus
On Mon, 23 Dec 2002, Beauford.2002 wrote:
> I have a function at the bottom of my script which is called from withing an
> if/else statement. If I take it out of the if/else and just call the
> function it works fine (except I don't get the results I want). So it
> appears where you are calling it from does matter. See the examples below.
> This isn't the first time either, I have had to redo several scripts for
> this project because of it. If I'm doing this wrong based on the examples
> below, please let me know. Thanks.
>
> i.e.
>
> This doesn't work. This does.
>
> some code ...... some code
> .........
>
> If ($bob) { gotofunction($bob); } gotofunction($bob);
> elseif ($sally) { gotonextfunction($sally); }
> gotonextfunction($sally)
> else { gotolastfunction(); }
> gotolastfunction()
> some other code ..... some other
> code
>
> function gotofunction($bob) function
> gotofunction($bob)
> function gotonextfunction() function
> gotonextfunction()
> function gotolastfunction() function
> gotolastfunction()
>
>
> ----- Original Message -----
> From: "Rasmus Lerdorf" <[EMAIL PROTECTED]>
> To: "Beauford.2002" <[EMAIL PROTECTED]>
> Cc: "PHP General" <[EMAIL PROTECTED]>
> Sent: Sunday, December 22, 2002 11:16 PM
> Subject: Re: [PHP] Undefined Functions
>
>
> > An undefined function error has nothing to do with where you are calling
> > the function from. It has to do with whether or not you have defined the
> > function you are calling.
> >
> > -Rasmus
> >
> > On Sun, 22 Dec 2002, Beauford.2002 wrote:
> >
> > > Hi,
> > >
> > > I previously asked a question about getting undefined function errors in
> my
> > > script and someone mentioned that it may be that I am calling it from
> within
> > > an if or else statement. This turned out to be the case. Now the
> question -
> > > is there a way around this? What I need to do resolves around many
> different
> > > conditions, and depending on the what's what I call the necessary
> function.
> > > I have looked my script over and over and can not see any other way of
> doing
> > > this. I am fairly new to PHP and maybe there is a better way, and I'm
> open
> > > to suggestions.
> > >
> > > TIA
> > >
> > > Example:
> > >
> > > if ($a == $b) call function one;
> > >
> > > elseif ($a > $b) call function two;
> > > elseif ($a == $c) call function two;
> > > elseif ($a < $b) call function two;
> > > elseif ($c > $b) call function two;
> > > elseif ($d == $e) call function two;
> > >
> > >
> > >
> > > --
> > > PHP General Mailing List (http://www.php.net/)
> > > To unsubscribe, visit: http://www.php.net/unsub.php
> > >
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php