在smarty文件夹下建立一个test文件夹,test下建立如下:
编辑test.php如下:
<?php require('../smarty/Smarty.class.php'); $smarty = new Smarty(); //五配置 $smarty->left_delimiter = "{"; $smarty->right_delimiter = "}"; $smarty->template_dir ="tpl"; $smarty->compile_dir ="template_c"; $smarty->cache_dir ="cache"; //开启缓存的另两个配置 $smarty->caching =true; $smarty->cache_lifetime =120; $smarty->assign('hello','你好');//赋值变量 $smarty->display('test.html'); ?>
在tpl中建立test.html,输入{$hello}
在浏览器中测试test.php
成功输出“你好”