一,php 脚本(test.php)
$smarty = new sys_smartywork(cron_home./modifyinfo/tpl,cron_home./modifyinfo/tpl_c); $hash = array();$info = array();$info ['smarty'] = 'i am smarty!';$info ['php'] = 'i am php';$hash['arrinfo'] = $info;//进行模板变量替换 $smarty->assign($hash); //编译并显示位于./templates下的index.htm模板 $msg = $smarty->display('test.tpl');
二,tpl 脚本('test.tpl')
{{$arrinfo.smarty}}------------{{ php }} //php给smarty变量赋值 $this->_tpl_vars['name'] = 'hello world!'; {{/php}}{{$name}}
三,显示i am smarty!
------------
hello world!