include

WBOY
WBOYOriginal
2016-06-23 13:29:431144browse

echo 'ended<br/>';include './k.php';echo 'ended<br/>';


被包含的文件k.php 是在那里编译的?被包含进来才编译,然后再执行?还是被编译了之后再包含进来执行?


回复讨论(解决方案)

这种问题说不大清楚,要看源码才能知道
但是可以做个测试

file_put_contents('x.php', "<?php echo 1;");include 'x.php';file_put_contents('x.php', "<?php echo 2;");include 'x.php';
12

@xuzuning 测试结果是什么呢?我测试了 还是不懂啊

输出了 1 和 2
显然是动态加载的

@xuzuning  不是我 我知道是执行到那条语句才加载包含进来 我想知道的是 那里编译的?被包含进来后编译,然后再执行?还是被编译了之后再包含进来执行?

当然是加载的时候编译啦

比如
file_put_contents('x.php', " include 'x.php'; //自然就不可能预先加载和编译 x.php 啦

哦 @xuzuning  就是说 index.php 里面的include ‘k.php’; 文件,是编译好了(成了二进制代码)再拿到index.php 里面执行 是这样吗?

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn