【发布时间】:2013-06-12 15:15:44
【问题描述】:
我正在编写 PHP 代码,我有函数,在这个函数中我有包含,它工作正常,但是如果我在这个包含文件中编写新代码会出错
错误:
Notice: Undefined variable: text
功能:
function inc($templateinc){
if(file_exists(Fsys.Fview.$templateinc)){
include Fsys.Fview.$templateinc;
}
else {
include Fsys.Fview.'errors/404.php';
}
}
我在哪里打印功能:
$text = "text";
inc("main/index.php");
main/index.php 文件:
echo $text;
我该如何解决这个问题?
谢谢
【问题讨论】:
-
问题解决了!我要添加全局 $tpl;在函数中,我将其添加到模板中: $tpl["giorgi"] = "Giorgi"; $tpl["bulia"] = "bulia";谢谢大家!
标签: php function templates include