Bug #17055: Must declare function before referencing when in the scope of an if statement

From: Date: Mon, 06 May 2002 23:38:04 +0000
Subject: Bug #17055: Must declare function before referencing when in the scope of an if statement
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-7093@lists.php.net to get a copy of this message
From: spamsucks86@comcast.net Operating system: Windows 2000 Pro PHP version: 4.1.2 PHP Bug Type: Scripting Engine problem Bug description: Must declare function before referencing when in the scope of an if statement 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 bug report at http://bugs.php.net/?id=17055&edit=1 -- Fixed in CVS: http://bugs.php.net/fix.php?id=17055&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=17055&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=17055&r=needtrace Try newer version: http://bugs.php.net/fix.php?id=17055&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=17055&r=support Expected behavior: http://bugs.php.net/fix.php?id=17055&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=17055&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=17055&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=17055&r=globals

« previous php.bugs (#7093) next »