PHP 4.0 Bug #10171 Updated: calling function before it is defined only works in same file
| From: | cynic@php.net | Date: | Thu, 05 Apr 2001 09:03:25 +0000 |
| Subject: | PHP 4.0 Bug #10171 Updated: calling function before it is defined only works in same file | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-50918@lists.php.net to get a copy of this message | ||
ID: 10171
Updated by: cynic
Reported By: aboyd@ssti.com
Status: Open
Old-Bug Type: Scripting Engine problem
Bug Type: Documentation problem
Assigned To:
Comments:
problem here is that include()s & require()s are runtime thingies. I got bitten by this just
yesterday: if you e. g. redeclare a function in a require()d file, the 'fatal error: function
redeclaration...' does appear, but at runtime, not during compilation.
Anyway, this is what Andi told me on the subject:
The main reason [require() was changed to happen at run time rather than at compile time] was that
it was supposed to improve performance and it didn't. It actually tended to slow things down.
Removing this also allowed us to reduce the memory usage of PHP scripts (not as important).
(...)
It really sucked and we managed to clean up some code and internals due to taking it out. I
wouldn't want to put it back in.
So, this is by design. -> docuprob
Previous Comments:
---------------------------------------------------------------------------
[2001-04-04 19:05:28] aboyd@ssti.com
Define a function. Put a call to that function BEFORE it is defined. That works, as documented.
Now put the function in an include()'d or require()'d file. Call the function before the
include() or require(). It fails.
Since the code is pre-compiled beforehand, shouldn't the function calls still work? If this is
"as designed" it might be nice to place a caveat in the documentation that states
"you can call a function before you define it ONLY if the function isn't buried in an
include()."
---------------------------------------------------------------------------
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=10171&edit=2