Re: Function Declared in Included File Not Being Found
| From: | Richard Lynch | Date: | Sun, 13 May 2007 05:38:27 +0000 |
| Subject: | Re: Function Declared in Included File Not Being Found | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-254867@lists.php.net to get a copy of this message | ||
On Fri, May 11, 2007 3:43 pm, Chris wrote:
> Hello,
>
> According to the PHP manual on functions (http://www.php.net/manual/
> en/language.functions.php):
>
> "In PHP 3, functions must be defined before they are referenced. No
> such requirement exists since PHP 4. Except when a function is
> conditionally defined..."
Does moving the require BEFORE the if/else change anything?
> If that is true then why does the following not work as I expect?
Not sure, really...
Seems like you're right, but maybe I'm also missing something.
If you take out the 'require' statements, and just put c inside a,
does it work?
> I expect the result to be "Function was called!" but it actually is
> "Function test() does not exist!".
Perhaps the if (function_exists()) business is trying to be "smart"
and is run because at the time it was compiled, the function didn't
exist, so you could define the function there -- which is a much more
common idiom than what you are doing, truth to tell...
--
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/browse/from/lynch
Yeah, I get a buck. So?