[英]Set variables for PHP files, so I could include these variables everywhere
[英]How can I include 2 php files variables?
我用例子描述了我的問題:
-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中看到
但現在我想在[我的問題]中為echo添加一個變量,該變量需要funcfile2.php包含
和funcfile2只包含在index.php中
我能做什么?
將funfile2.php包含在funfile1.php中 。 當你在index.php中包含funfile1.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
?>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.