|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2014-09-22 17:49 UTC] requinix@php.net
-Status: Open
+Status: Not a bug
[2014-09-22 17:49 UTC] requinix@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2026 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 07 04:00:01 2026 UTC |
Description: ------------ PHP allows calls to functions that have not yet been defined as long as they are defined at some point in the script. However, this behavior is not consistent when applied to Closures, as function calls within a closure will fail if they are not defined before they are made even if the function definition is contained within the same closure. If the function in question is defined outside of a closure but after the closure is created, the script will also proceed as expected. Test script: --------------- test(); function test(){ echo "Test works\r\n"; } //output: Test works $closure = function(){ closure_test(); function closure_test(){ echo "Closure test works\r\n"; } }; $closure(); //expected output: Closure test works //actual output: Fatal error: Call to undefined function closure_test() Expected result: ---------------- Test works Closure test works Actual result: -------------- Test works Fatal error: Call to undefined function closure_test()