|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-07-26 01:23 UTC] mccarre at uwindsor dot ca
[2009-07-26 01:37 UTC] mccarre at uwindsor dot ca
[2011-01-01 16:18 UTC] jani@php.net
-Status: Open
+Status: Bogus
-Package: Feature/Change Request
+Package: *General Issues
[2011-01-01 16:18 UTC] jani@php.net
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Nov 20 17:00:01 2025 UTC |
Description: ------------ Because files are included at run time where the instruction is located, it may not ever be evaluated. This is to be expected. However, this creates a problem with code that may call a function that is in one of the preceding included files. You generally want to call that function LAST, only after you've included all other files. (This is for nested include relations) The only scenario I have found this relevant thus far is calling php functions using AJAX. Reproduce code: --------------- --- From manual page: function.include-once --- I'll provide a simple example, because the one I came upon is too large. Imagine you have fileA.php: <?php include_once "fileB.php"; include_once "fileC.php"; include_once "callA.php"; //when fileB.php includes callA.php and callA calls fncA and it tries to call fncC, although fncC is in this files includes list, that line has yet to be executed, therefor it will not be able to find the function. If you could include_last "callA.php", then the first include_last "callA.php" in fileB.php would be ignored, and the callA.php in fileA.php would be included after fileC.php is included. =) function fncA() { fncC(); } ?> You normally wouldn't do the following, but if there was generic code to call an AJAX function here it would do this. fileB.php: <?php //reminder that include_once "fileC.php"; hasn't been executed yet. include_once "callA.php"; ?> fileC.php: <?php fncC(){ print "hello"; } ?> callA.php: <?php fncA(); ?> I posted another example in the comments of include_once. Expected result: ---------------- function not found. Actual result: -------------- with include_last, the function will be called and "hello" would be printed.