Home  >  Article  >  php教程  >  smarty 模板if else使用实例与入门教程

smarty 模板if else使用实例与入门教程

WBOY
WBOYOriginal
2016-06-08 17:27:361120browse

标签是给Smarty的指令符,以模板定界符包住。这些指令符可以是变量,以$符号代表函数、逻辑 或 流程控制 语法。Smarty 允许 PHP 程式设计师以Smarty 标签去定义可存取的函数

<script>ec(2);</script>

smarty 模板if else使用实例与入门教程
smarty 主要功能是完成美工与程序分离,并且使用的缓存技术,减轻服务器的负载,
smarty 以在文件中放置特殊的“Smarty标签”来产生网页内容。这些标签会被处理并替换成其他的内容。

 

*/

require('smarty/libs/Smarty.class.php教程');

$tpl = new Smarty();
$tpl->template_dir   = 'd/'
$tpl->compile_dir    = 'd/template_c';

$tpl->compile_check   = false;//$cfg['debug'];
$tpl->debugging      = false;
$tpl->caching       = false;
$tpl->cache_lifetime  = 3600;

$tpl->left_delimiter  = '';

$array = 'www.111cn.net'
$tpl->assign('dataList', $array);
$tpl->display('a.tpl');

/*
a.tpl

 

 echo 'aaa';

还有另一种方法

{if $name eq 'Fred'}
    Welcome Sir.
{elseif $name eq 'Wilma'}
    Welcome Ma'am.
{else}
    Welcome, whatever you are.
{/if}

{* an example with "or" logic *}
{if $name eq 'Fred' or $name eq 'Wilma'}
   ...
{/if}

本文章原创于www.111cn.net转载注明出处

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn