Edit report at https://bugs.php.net/bug.php?id=46189&edit=1

 ID:                 46189
 Updated by:         johan...@php.net
 Reported by:        noah at missionecommerce dot com
 Summary:            php needs a compile-time include/require like
                     #include
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Linux
 PHP Version:        5.2.6
 Block user comment: N
 Private report:     N

 New Comment:

As a historic remark: We had such behavior in PHP 3, where include was 
run-time, and require compile-time. We got rid of it intentionally. Use 
functions or other structures to solve your issue.


Previous Comments:
------------------------------------------------------------------------
[2012-04-13 21:23:05] ni...@php.net

How about putting the code into a function and including it just once?

------------------------------------------------------------------------
[2008-09-27 10:12:35] noah at missionecommerce dot com

Description:
------------
Using include/require in a loop causes horrible preformance, because of the 
additional stat, file read, and opt-code compile on every loop iteration.

PHP really needs a method to do compile-time includes/requires as well as the 
current run-time include/require.

I would like to be able to do #include like in C and have the compiler insert 
the contents of the file into the script BEFORE compilation.

This shouldn't be a complicated feature addition, and it would make life alot 
easier when developing with large projects with alot of reusable code.


Reproduce code:
---------------
for( $i = 0; $i < 1000; $i ++ ) {

// I want run this code by including the file
// But this code is not appropriate to make a function for
// And its very long, so I dont just want to paste the code inside
// this loop because it makes developement more confusing

include '/www/some_code_snippet.php';


}

Expected result:
----------------
Although I knew include was a run-time event, I was hoping
behavior to #include in C.



Actual result:
--------------
Tracing the code, I found it produced 1000 file stats, 1000 file reads, and 
1000 opt-code compiles


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=46189&edit=1

Reply via email to