note 77802 deleted from function.function-exists by nlopess
| From: | nlopess@php.net | Date: | Thu, 13 Sep 2007 17:13:59 +0000 |
| Subject: | note 77802 deleted from function.function-exists by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130476@lists.php.net to get a copy of this message | ||
Note Submitter: White-Gandalf
----
I stumbled over the same problem as "eddiec" (users not able or not willing to use
"_once"-suffixes).
A possible alternative explanation for the behavior:
If a file is included, it is possibly parsed every include-time.(?)
While parsing, every function in global scope is tried to register. THIS gets wrong, when multiple
times included, and it produces an error.
If functions are defined within block scopes, their registration seems to be delayed until execution
of such a block. Thus, not the function "function_exists" functions wrong, but simply the
philosophy of the interpreter produces such results.
Thus, the same effect can be achieved by simply putting block braces around the contents of an
include_once file:
if (function_exists('function_in_question')) return;
{
function function_in_question(...)
{
...
}
...other stuff
}
...which is equivalent to...
if (!function_exists('function_in_question'))
{
function function_in_question(...)
{
...
}
...other stuff
}