smarty---smarty的第一个示例

简单的输出

<?php
//引进smarty的类文件
require_once "../../libs/Smarty.class.php";//引入类文件

$smarty = new Smarty();//创建对象

$smarty->template_dir = '../templates/';//配置模板目录
$smarty->compile_dir = '../templates_c/';//配置编译目录
$smarty->config_dir = '../configs/';//配置配置文件目录
$smarty->cache_dir = '../cache/';//配置缓存目录

$smarty->debugging = true;//启用smarty的dedug的调试true使用,false不启用

$smarty->assign('name','zhangdapeng');//传递参数
$smarty->display('index.pl');//要显示的文件
?>

index.pl文件的内容,放在 templates这个目录下的

{* Smarty注释 *}
Hello {$name}, Welcome to Smarty!

 

 

 

你可能感兴趣的:(smarty---smarty的第一个示例)