Re: Undefined Functions
| From: | Leif K-Brooks | Date: | Mon, 23 Dec 2002 19:37:53 +0000 |
| Subject: | Re: Undefined Functions | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-129222@lists.php.net to get a copy of this message | ||
Try defining them at the top instead...
Beauford.2002 wrote:
Then based on the one below that doesn't work, what is the problem with it? As I said, the functions are at the bottom of the script. The only thing after them is the closing ?>. I also said that they work if I don't call them from within an if/else. This tells me it is not where it is defined but where it is being called from. Your saying this doesn't matter, but have not given any reasons for my problems. If you could elaborate on this it would be appreciated. Beauford ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Beauford.2002" <beauford.2002@rogers.com> Cc: "PHP General" <php-general@lists.php.net> Sent: Monday, December 23, 2002 11:14 AM Subject: Re: [PHP] Undefined FunctionscallingLike 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:withing anI have a function at the bottom of my script which is called frombelow.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 examplesexamplesThis 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 thecodebelow, please let me know. Thanks. i.e.This doesn't work. This does.some code ...... somegotofunction($bob);......... If ($bob) { gotofunction($bob); }elseif ($sally) { gotonextfunction($sally); } gotonextfunction($sally)else { gotolastfunction(); }gotolastfunction()some other code ..... some othercodefunction gotofunction($bob) functiongotofunction($bob)function gotonextfunction() functiongotonextfunction()function gotolastfunction() functiongotolastfunction() ----- Original Message ----- From: "Rasmus Lerdorf" <rasmus@php.net> To: "Beauford.2002" <beauford.2002@rogers.com> Cc: "PHP General" <php-general@lists.php.net> Sent: Sunday, December 22, 2002 11:16 PM Subject: Re: [PHP] Undefined FunctionsAn undefined function error has nothing to do with where you are
thethe function from. It has to do with whether or not you have defined
errors infunction you are calling. -Rasmus On Sun, 22 Dec 2002, Beauford.2002 wrote:Hi, I previously asked a question about getting undefined function
frommyscript and someone mentioned that it may be that I am calling it
question -withinan if or else statement. This turned out to be the case. Now the
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
I'mdoingthis. I am fairly new to PHP and maybe there is a better way, and
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- The above message is encrypted with double rot13 encoding. Any unauthorized attempt to decrypt it will be prosecuted to the full extent of the law.open-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.phpto 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