ID: 17055
Updated by: [EMAIL PROTECTED]
Reported By: [EMAIL PROTECTED]
-Status: Open
+Status: Suspended
-Bug Type: Scripting Engine problem
+Bug Type: Feature/Change Request
-Operating System: Windows 2000 Pro
+Operating System: All
PHP Version: 4.1.2
New Comment:
This is not really a bug, as PHP only 'remembers' functions as soon as
they are seen by the compiler.
Because the compiler does not know if this specific branch will be
executed, it doesn't add the function to the function table
immediately, but waits until it actually 'hits' the function
declaration.
Therefore the function will nto be defined at the locate where you get
your error.
The only way to prevent this is to move out the function declaration
out of the branch and in the main scope of the script. Then it doesn't
matter if you define it before or after the call to the function.
I'm making this report a suspended function/request, as I don't see any
fast implementation of this.
Derick
Previous Comments:
------------------------------------------------------------------------
[2002-05-06 19:38:03] [EMAIL PROTECTED]
if (1==1) {
if (1==2) {
echo 'blah';
}
else { test('test'); } <--RIGHT HERE
function test ($blah) {
echo $blah;
}
}
This script gives the error: Fatal error: Call to undefined function:
test() <line 6>.
PHP should have recognized that since the first if statement was true,
all functions in the scope of that if statement should be declared. If
I move the function declaration to before I use it, it works.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17055&edit=1