Re: [PHP] Undefined Functions
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
Re: [PHP] Undefined Functions
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
Re: [PHP] Undefined Functions
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 [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Monday, December 23, 2002 11:14 AM Subject: Re: [PHP] Undefined Functions 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Functions
On Monday 23 December 2002 11:11 am, Beauford.2002 wrote: Then based on the one below that doesn't work, what is the problem with it? your example wasn't runnable (since parts of it were is the attached a fair example of what you're trying to do? i don't have any problem with it. it works as expected with no undefined function problems. now, if i were to have an elseif ($b==9) b9(); in there, then i'd expect that error. can you distill the problem to a runnable example which demonstrates the problem for you and post the example? tiger -- Gerald Timothy Quimpo tiger*quimpo*org gquimpo*sni-inc.com tiger*sni*ph Public Key: gpg --keyserver pgp.mit.edu --recv-keys 672F4C78 Veritas liberabit vos. Doveryai no proveryai. bb.php Description: application/php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Functions
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 [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Monday, December 23, 2002 11:14 AM Subject: Re: [PHP] Undefined Functions 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 -- 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.
Re: [PHP] Undefined Functions
I have no idea what you have done wrong. I am simply telling you how it works. Create a small test script that reproduces the problem and we can help you. What you have provided so far does not give us anything to work with. Try this, for example: ? if(true) func1(); else func2(); function func1() { echo 1; } function func2() { echo 2; } ? When you run this you will see that it prints out 1 which should satisfy you that you can safely call functions inside conditionals and have them be defined at the bottom of your script. Your job now is to tell us how your script differs from the above test script, because as far as I have understood this is the exact situation you say isn't working. -Rasmus On Mon, 23 Dec 2002, 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 [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Monday, December 23, 2002 11:14 AM Subject: Re: [PHP] Undefined Functions 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Undefined Functions
Finally got it working, but I have no idea how. I rewrote the script changing a few if's and elseif's so there weren't as many, but still calling the functions from the if/else statements. The format of the new script is the same as the old one, and other than a few modifications, I still can't see where the old one failed. In any event, I appreciate the help from all who responded. Beauford - Original Message - From: Rasmus Lerdorf [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Monday, December 23, 2002 2:40 PM Subject: Re: [PHP] Undefined Functions I have no idea what you have done wrong. I am simply telling you how it works. Create a small test script that reproduces the problem and we can help you. What you have provided so far does not give us anything to work with. Try this, for example: ? if(true) func1(); else func2(); function func1() { echo 1; } function func2() { echo 2; } ? When you run this you will see that it prints out 1 which should satisfy you that you can safely call functions inside conditionals and have them be defined at the bottom of your script. Your job now is to tell us how your script differs from the above test script, because as far as I have understood this is the exact situation you say isn't working. -Rasmus On Mon, 23 Dec 2002, 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 [EMAIL PROTECTED] To: Beauford.2002 [EMAIL PROTECTED] Cc: PHP General [EMAIL PROTECTED] Sent: Monday, December 23, 2002 11:14 AM Subject: Re: [PHP] Undefined Functions 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
[PHP] Undefined Functions
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
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] undefined functions question
This has been an ongoing problem, when I include a file which contains a call to a function I get undefined function errors but when I try to include the file containing the function I get cannot redeclare function error messages, I can't win how do I make sure my functions are available to any script whether included or whatever. -Mark -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] undefined functions question
This has been an ongoing problem, when I include a file which contains a call to a function I get undefined function errors but when I try to include the file containing the function I get cannot redeclare function error messages, I can't win how do I make sure my functions are available to any script whether included or whatever. is the function declared before file is included? I'm not sure but this may cause a problem. As for getting the redeclare error, are you sure the function is not declared in the page or any other file that is included. Sorry if this seems a little obvious.. Regards M@ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] undefined functions question
Try include_once() for your includes instead of simply include(). --toby Matt Williams wrote: This has been an ongoing problem, when I include a file which contains a call to a function I get undefined function errors but when I try to include the file containing the function I get cannot redeclare function error messages, I can't win how do I make sure my functions are available to any script whether included or whatever. is the function declared before file is included? I'm not sure but this may cause a problem. As for getting the redeclare error, are you sure the function is not declared in the page or any other file that is included. Sorry if this seems a little obvious.. Regards M@ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]