error due to function definition
am 28.12.2007 02:03:36 von kenoli
I want to call a function if it has been defined and not call it if it
hasn't. I am using this code:
if (function_exists(editForm())) { editForm(); }
I also tired:
if (editForm()) { editForm(); }
When I first implement this conditional in this script, the function
has not yet been defined. Later, when the script is run again after a
post submit, the function gets defined and the conditional then
results in the function being called.
When I run this on my local machine using PHP Version 5.2.2 both of
these scripts run fine, doing nothing when it is not defined and
calling it when it is. It shows no errors.
When I upload this to my web server which is using php 5.2.5, and run
this script I get the following error:
"Fatal error: Call to undefined function editform()"
when it gets to this conditional. Can anyone tell me what is going on
here. Has something changed between php 5.2.2 and 5.2.5?
I have searched everywhere and not been able to find any explanation
for my problem.
How do I accomplish this procedure?
Thanks,
--Kenoli
Re: error due to function definition
am 28.12.2007 02:34:41 von Vince Morgan
"kenoli" wrote in message
news:81eae516-e0d4-4f84-9420-dc675360e796@s8g2000prg.googleg roups.com...
> I want to call a function if it has been defined and not call it if it
> hasn't. I am using this code:
>
> if (function_exists(editForm())) { editForm(); }
>
The manual says the function name should be a string, and indicates the
brackets aren't required.
Ie
if (function_exists('editForm')) { editForm(); }
> I also tired:
>
> if (editForm()) { editForm(); }
I imagine this should cause a problem, as it will try to call the function
in the evaluation, and if it isn't defined flip out. If the function
returns a boolean then the matter is further complicated.
HTH
Vince
Re: error due to function definition
am 28.12.2007 07:37:51 von kenoli
Thanks -- Worked perfect. Now I remember reading something about that
once.
--Kenoli
On Dec 27, 5:34=A0pm, "Vince Morgan"
wrote:
> "kenoli" wrote in message
>
> news:81eae516-e0d4-4f84-9420-dc675360e796@s8g2000prg.googleg roups.com...
>
> > I want to call a function if it has been defined and not call it if it
> > hasn't. =A0I am using this code:
>
> > if (function_exists(editForm())) { editForm(); }
>
> The manual says the function name should be a string, and indicates the
> brackets aren't required.
> Ie
> if (function_exists('editForm')) { editForm(); }
>
> > I also tired:
>
> > if (editForm()) { editForm(); }
>
> I imagine this should cause a problem, as it will try to call the function=
> in the evaluation, and if it isn't defined flip out. =A0If the function
> returns a boolean then the matter is further complicated.
> HTH
> Vince