我遇到了smarty问题" fetch"。它没有加载内容。我检查了找到的地方
$subject = $smarty->fetch("emailtpl:emailsubject");
$message = $smarty->fetch("emailtpl:emailmessage");
当我尝试打印$ subject和$ message变量时,它们是空白的。我想了解这个问题。请帮忙。代码是: -
#$subject :- This variable has value like "forgot password"
#$message :- This variable has value like email content
include_once(ROOTDIR . "/includes/smarty/Smarty.class.php");
$smarty = new Smarty();
$smarty->caching = 0;
$smarty->compile_dir = ROOTDIR . "/" . $templatecompilerpath;
$smarty->compile_id = md5($subject . $message);
$smarty->register_resource("emailtpl", array( "emailtpl_template", "emailtpl_timestamp", "emailtpl_secure", "emailtpl_trusted" ));
$smarty->assign("emailsubject", $subject);
$smarty->assign("emailmessage", $message);
#It assigns value
$smarty->assign("enc", $enc); //enc is vaiable having vluae defined
Then it takes the value as
$subject = $smarty->fetch("emailtpl:emailsubject");
$message = $smarty->fetch("emailtpl:emailmessage");
但是当我打印$ subject和$ message变量时。他们是空白的。我不明白,这段代码是如何工作的以及emailtpl定义的地方。
如何调试它。请帮忙
答案 0 :(得分:0)
这不起作用。 Fetch用于将输出保存在变量中。
获取需要一个模板文件。此模板文件将填充您的分配,并在获取保存在$ subject中后。
顺便说一下。你想用这段代码做什么?!