gpt4 book ai didi

php - PHP 是否从我使用 opcache.opcache_compile_file() 编译的文件中的包含执行文件?

转载 作者:行者123 更新时间:2023-12-04 17:35:45 26 4
gpt4 key购买 nike

[PHP 文档 opcache.opcache_compile_file说:

This function compiles a PHP script and adds it to the opcode cache without executing it.



如果我使用 opcache_compile_file() 编译文件,并且该文件包含其他文件(通过 include()require() 等),包含的文件会被执行吗?或者将包含的文件编译并添加到 opcache 中?

编辑

从评论中提出的观点来看,包含的文件是否也添加到缓存中?还是 opcache_compile_file()简单地忽略包含(也许是最佳行为)?

最佳答案

有同样的问题,我在谷歌上搜索,并通过与 stackoverflow 研究员在 xampp 中打开 opcache 得到了一些结果
所以我做了我成功的愚蠢测试..
在 php.ini 我把这些

[opcache]
zend_extension=C:\xampp\php\ext\php_opcache.dll
opcache.enable=1
opcache.enable_cli=1
所以在 htdocs\stupidtest*index.php* 我把这个:
<?php
opcache_compile_file('test.php');
test();
test.php 我放
<?php
function test(){
echo 'yep';
}
和另一个名为 的文件the_answer_i_need.php
<?php
include('test.php');

print_r(opcache_is_script_cached('test.php'));

test();
?>
现在让我们玩游戏:
首先运行 index.php
http://localhost/test/index.php 在我的情况下
然后我运行 the_answer_i_need.php
http://localhost/test/the_answer_i_need.php 在我的情况下
我得到的结果是
1是的
1 means boolean true
'yep' means the function called are included from cache cause the previous result was **true**

*job done,we're good*
自 2002 年以来,我编写了世界上最快的 php 框架,这个技巧将允许我将框架核心的某些部分切换为 php 之后的第二个预处理器,并获得大约 40% 的速度。

关于php - PHP 是否从我使用 opcache.opcache_compile_file() 编译的文件中的包含执行文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56711962/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com