在PHP中,include()如何正常工作?(In PHP, how does include() exactly work?)
include('./code.php');
工作? 我理解这相当于直接在包含发生的地方“粘贴”代码,但是,例如:如果我有两个页面,
page1.php
和page2.php
,我需要在./code.php
操作不同的变量和函数,include()
创建了./code.php
的副本,或者它本质上是链接回实际页面./code.php
?How does
include('./code.php');
work? I understand it is the equivalent of having the code "pasted" directly where the include occurs, but, for example:If I have two pages,
page1.php
andpage2.php
, of which I would need to manipulate different variables and functions in./code.php
, doesinclude()
create a copy of./code.php
, or does it essentially link back to the actual page./code.php
?
原文:https://stackoverflow.com/questions/12117796