ID: 41383 User updated by: chris at dented-planet dot net Reported By: chris at dented-planet dot net Status: Open Bug Type: Unknown/Other Function Operating System: Mac OS X PHP Version: 5.2.2 New Comment:
Okay, it was explained to me why this doesn't work. That's why I said that it might not be a bug. It isn't a bug, indeed. The only thing that is buggy is my ability to read the documentaion more thoroughly. Case Closed Previous Comments: ------------------------------------------------------------------------ [2007-05-13 10:38:59] chris at dented-planet dot net Description: ------------ The documentation on functions (http://www.php.net/manual/en/language.functions.php) says: "In PHP 3, functions must be defined before they are referenced. No such requirement exists since PHP 4. Except when a function is conditionally defined..." I don't understand why the following code (in three different files BTW) doesn't work as expected. It doesn't seem to be conditionally defined. Tested with PHP 4.4.4-CLI, PHP 5.2.1, PHP 5.2.2. I am openminded that this may not be a bug but I can't seem to find an explanation. Reproduce code: --------------- FILE a.php: <?php error_reporting(E_ALL | E_NOTICE); echo "FILE 'a.php'\n"; if (function_exists('test')) { echo test(); } else { echo "function 'test()' doesn't exist!\n"; } require 'b.php'; ?> ------ FILE b.php <?php echo "FILE 'b.php'\n"; require 'c.php'; ?> ------ FILE c.php <?php echo "FILE 'c.php'\n"; function test() { return "function test() was called!\n"; } ?> Expected result: ---------------- SIGNIFICANT expected result: 'function test() was called!' is echoed. Other output is for debugging. Actual result: -------------- Actual result: 'function 'test()' doesn't exist!' is echoed. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=41383&edit=1