smarty的认识和知识点总结:
{if $name == ''}
用户名不能为空
{/if}
{if $name == ''}
用户名不能为空
{else}
正确
{/if}
$ar = array(1,2,4,22,4);
foreach($ar as $vo){
echo $vo;
}
{foreach from=$ar item=vo}
{$vo}
{/foreach}
create table t_category(
id int primary key auto_increment,
title varchar(20) not null default ''
);
create table t_new(
id int primary key auto_increment,
title varchar(20) not null default '',
cont varchar(4000) not null default ''
);
smarty知识点总结
重点内容
smarty:php模板引擎
smarty特点:编译速度快,使用范围广!
1:自定义函数
1.php
function test3($args){
return "";
}
$smarty->register_function("test3","test3");
2.tpl
{test3}
2:自定义块
function test4($args,$con){
return "";
} //调用test4 原函数
$smarty->register_block("test4","test4");
3:自定义变量调节器 插件
smarty/libs/plugins
modifiter.test9.php
function smarty_modifier_test9($str){
return "";
}
4:smarty/libs/plugins 插件
function.test6.php
function smarty_function_test6($args,&$smarty){
return "";
}
5:插件方式
smarty/libs/plugins
block.test7.php
function smarty_block_test7($args,$con,&$smarty){
return "";
}
6:加载模板
{include file="1.tpl"}
7:smarty表签原样输出
{literal}
{$name}
{/literal}
8:foreach
{foreach from=$rows item=vo}
{foreachelse}
{/foreach}
9:模板页面使用php指令
{php}
echo "oho";
10:smarty缓存
10.1:创建缓存文件夹
10.2:$smarty->caching= true;
$smarty->lifetime = 60;