include_once '../libs/Smarty.class.php';
$smarty = new Smarty;
$smarty->left_delimiter ='<<'; //左符号为 << $smarty->right_delimiter='>>'; //右符号 为 >>
$smarty->assign('test',$te);
//将$test的值付给test,在模板页tpl中显示用{$test}
$smarty->assign('arr',$arr);
{foreach item=item from=$arr key=ke name=foe}
$item
{/foreach}
//此处的$item相当于$arr[$ke],foreach序列化{$smarty.foreach.foe.iteration}
{section name='test' loop=$arr}
{$smarty.section.name.iteration}//使输出序列化,序号从1开始,index从0开始
{$arr[test]}
{/section}
$smarty->display('test.tpl');
我叫{$str1|cat:"李白"};//输出结果就是:我叫 $str1 李白
{$str2|rdate_format:"Y%-m%-d%"} //输出结果格式化$str2日期,形如0000-00-00
{$str3|indent:8:"*"} //$str3前缩进8个* 默认缩进的是空格
{$str4|lower} //$str4的小写形式
{$str4|upper} //$str4的大写形式
{$url|escape:"url"} //对$url相关特殊字符进行替换
<tr bgcolor='{cycle values="#EBEBEB,#ACABAB"}'>//tr背景交替 颜色分别为#EBEBEB,#ACABAB
{$str|regex_replace:"~[0-9]~":"asd"} //如果$str匹配[0-9]输出asd
{$str|replace:"net":"com"} //将$str中的net全部替换成com
{include file="top.tpl"}
{insert name="getCurrentTime" assign="current_time" script="time.inc.php"}
当前时间为{$current_time};
{/insert}
<?php
function smarty_insert_getCurrentTime
{
return gmdate('l,j F Y g:i a T');//获得当前日期及时间
}
?>
mailto{
mailto address="contact@smartyllc.com" subject="Smarty LLC Contact" encode="javascript"}
{conf_load file="test.conf" section="test"}
{#tt#}
[test] tt = 12122
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有