php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46821 include of same file is re-access and re-compiled each time within same script
Submitted: 2008-12-10 12:46 UTC Modified: 2008-12-15 21:32 UTC
From: php at pk dot freesurf dot fr Assigned:
Status: Not a bug Package: Performance problem
PHP Version: 5.2.8 OS: linux
Private report: No CVE-ID: None
 [2008-12-10 12:46 UTC] php at pk dot freesurf dot fr
Description:
------------
include "foo.php" within a loop is re-accessed & re-compile before execution each time...

php already knows that the file has been included (include_once generates an error), but does not remember the code within...

for source code clarity, has there is no macro-processor like in C, it is very usefull to use the include statement...

a function call is not appropriate in every case, as local variable scope can be a problem...
if there are 20 or more variable to be accessed, code will be not clear if they are part of function arguments,
neither the code will be clear if all variables are declared global.

so it is really an issue for me...

Reproduce code:
---------------
<?
for ($i=0;$i<10000;++$i)
{
include "foo.php";
}
?>

foo.php : hundreds of code lines

when content of foo.php is pasted inside the loop, execution time dramasticaly shorter..


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-12-10 15:19 UTC] jani@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php


 [2008-12-15 19:19 UTC] php at pk dot freesurf dot fr
of course it is not a bug, but it is a performance problem, that can be solved easyly...
 [2008-12-15 21:32 UTC] scottmac@php.net
APC provides this functionality and there is no intention to add this at the moment.
 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Sun Aug 09 17:01:23 2020 UTC