php学习之smarty 三种 值 获取方式

来源:互联网 发布:2017淘宝双11晚会 编辑:程序博客网 时间:2024/05/17 01:28

1.assign分配

$smarty->assign("title","测试标题");$smarty->assign("content","测试内容");

2保留变量

{$smarty.get.id}{$smarty.const.NIHAO}

3读取配置文件


{config_load file='tong.conf'}{#name#}//读取方式或者{smarty.config.name}


注: 

$s->assign($arr);//传的值是数组,则 模版里使用 键值作为变量 

$s->assign('hello',$arr);//如果这样的传值,则一个用 $hello.键值 如果键值为数字 则可使用 hello[0],hello[1]这种形式

$s->assign('hello2',array('a'=>array('b'=>'test'))); 则  $hello2.a.b = test


$s->append('test','a');

$s->append('test','b');

则 类似 $s->assign('test',array('a','b')); 可以用 $test[0] 也可以用 $test.0 

原创粉丝点击