Re: Function redefine ?
| From: | Alexander Wagner | Date: | Sun, 07 Jan 2001 19:23:40 +0000 |
| Subject: | Re: Function redefine ? | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-33107@lists.php.net to get a copy of this message | ||
Abe wrote:
> Does that mean PHP3 users are bound to use just one include file?
No, they are bound to be careful about what they include.
The solution to your problem is to rearrange your files. The files are
executed top down, so a function is defined only for the following
lines, not for the lines before (at least in php3, I'm not sure about
4). This is not checked during parse-time, but at execution time. So
you never run into trouble if your files look like this:
<?php
function f1()
{
}
function f2()
{
}
..
..
..
f1();
?>
The real execution (not the parsing) of the functions begins with the
first funtion call, so if you put it on the last line (or at least
below all the function definitions), this should fix your problem.
If the include-files contain function calls, the calls in the first
include-file may require something from file2, which will break you
code sind file2 isn't included yet. Move these calls to menu.php3, the
end of it, if possible, include all files at the beginning of
menu.php3, and it should work.
regards
Wagner
--
Sanity is calming, but madness is more interesting.