Stack Overflow for Teams is a private, secure spot for you and
your coworkers to find and share information.
Learn more
Ask Question
If I compile a file using
opcache_compile_file()
, and that file includes other files (via
include()
,
require()
, etc.), will the files that are included be executed? Or will the included files just be compiled and added to the opcache?
From a point raised in a comment, are the included files also added to the cache? Or does
opcache_compile_file()
simply ignore includes (maybe the optimal behavior)?
–
–
–
–
–
having the same question ,i googleize and i got some results by turning on opcache in xampp with stackoverflow fellows
so i did my succefull stupid test ..
in php.ini i put these
[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
and so in htdocs\stupidtest*index.php* i put this:
opcache_compile_file('test.php');
test();
in test.php i put
function test(){
echo 'yep';
and another file called the_answer_i_need.php
include('test.php');
print_r(opcache_is_script_cached('test.php'));
test();
Now let's play the game:
run first index.php
http://localhost/test/index.php in my case
then i run the_answer_i_need.php
http://localhost/test/the_answer_i_need.php in my case
the result i got is
1 means boolean true
'yep' means the function called are included from cache cause the previous result was **true**
*job done,we're good*
i wrote the fastest php framework in the wold since 2002 and this trick will allow me to switch some parts of framework's core as 2nd pre procesor after the php and to gain around 40% more speed.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.