PHP Smarty

459 查看

define('ROOT_PATH', dirname(FILE));

// 使用据对路径,引入Smarty
require ROOT_PATH . '/smarty/Smarty.class.php';

// 实例化smarty
$smarty = new Smarty();

// 根目录
$smarty->template_dir = ROOT_PATH . '/templates/';

// 编译目录
$smarty->compile_dir = ROOT_PATH . '/templates_c/';

// 配置文件目录
$smarty->config_dir = ROOT_PATH . '/configs/';

// 是否开启缓存
$smarty->caching = ture;

// 缓存目录
$smarty->cache_dir = ROOT_PATH . '/cache/';

// 定界符
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';

$smarty->assign('show', 'Curtis');
$smarty->display('demo.tpl');