【发布时间】:2014-01-07 13:02:15
【问题描述】:
smarty 中如何访问 PHP 中设置的变量的值?我的示例 PHP 代码是:
function searchTwitter() {
global $smarty;
$test1 = 'Sometext';
$smarty->assign("test1", $test1);
...
}
我的 .tpl 文件将包含以下部分:
test={$test1}
我希望这会在我的浏览器中显示以下内容:
test=Sometext
但事实并非如此。你能告诉我如何做到这一点吗?谢谢。
【问题讨论】:
-
看起来不错。输出是什么?
-
你是否包含了“include('Smarty.class.php');” ?
-
你正在使用函数。你需要在php中返回一个值
-
请参考这个网站。 smarty.net/quick_install 和 smarty.net/crash_course
-
@sroes 输出为
test=