0

我用例子来描述我的问题:

-index.php 文件内容:

<?php
require_once(funcfile1.php);
include(funcfile2.php);
?>
<div><?php echo $var1; ?></div>

-funcfile1.php 内容:

<?php
$var1 = 'html codes'.$var2.'htmlcodes'.**[MY QUESTION]**.'other html or php cods'
?>

您在 funfile1.php 中的索引文件 echo $var1 中看到

但现在我想在 [MY QUESTION] 中为 echo 添加一个变量,该变量需要 funcfile2.php 包括

和 funcfile2 只包含在 index.php

我能做些什么?

4

1 回答 1

2

funfile2.php包含 到funfile1.php中。当您将funfile1.php包含在 index.php 中时, funfile2.php文件也将包含在 index.php 文件中。

-funcfile1.php 内容:

<?php
include(funcfile2.php);
$var1 = 'html codes'.$var2.'htmlcodes'.**[MY QUESTION]**.'other html or php cods'
?>

index.php 的内容将是:

<?php
require_once(funcfile1.php); 
// remove include funcfile1.php from here as it was includeed in funcfile1.php
?>
于 2013-08-02T13:24:57.927 回答