首页 > php框架 > php smarty 目录引擎实例入门教程

php smarty 目录引擎实例入门教程

require(你的目录 . 'smarty/libs/Smarty.class.php');
/*
* 模版引擎
*/
$tpl = new Smarty();
$tpl->template_dir   = 模板目录;
$tpl->compile_dir    =解析目录 . 'tmp/template_c/';
$tpl->debugging      = false;
$tpl->caching       = 0;
$tpl->cache_lifetime  = 6000;
$tpl->left_delimiter  = '<!--{';
$tpl->right_delimiter  = '}-->';
首页smarty的配置完成下面来看个实例
$tpl->assign('cityid', "长沙");

我们的index.tpl模板文件

<%@LANGUAGE="JAVASCRIPT" CODEPAGE="936"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>这是我第一个模板引擎例子</title>
</head>
<body>
<!--{cityid}-->
</body>
</html>

显示结果为

长沙

好了简单吧,关于foreach item setion下次再次。


本文地址:http://www.phprm.com/frame/php_smarty_a.html

转载随意,但请附上文章地址:-)

标签:none

发表留言