smarty自定义函数
来源:互联网 发布:对讲机写频软件大全 编辑:程序博客网 时间:2024/05/24 04:53
自定义函数:b.php
<?PHPinclude("./init.inc.php");$tpl->assign("title","abc");//因为参数出现顺序无关,把参数保存到数组里面$tpl->register_function("title","fun1");function fun1($args){$a="";for($i=0;$i<$args["num"];$i++){ $a .= "<font size=".$args["size"].">".$args["content"]."</font><br>" ;}return $a;}//注册一个块$tpl->register_block("hello","fun2");//定义块函数function fun2($args,$content,&$a,&$b){$a="";for($i=0;$i<$args["num"];$i++){ $a .= "<font size=".$args["size"].">".$args["content"]."</font><br>" ;}return $a;}$tpl->display("a.html");?>
init.inc.php文件:
<?phprequire("./libs/Smarty.class.php");$tpl = new Smarty();$tpl->template_dir ='./templates';$tpl->compile_dir ='./templates_c';$tpl->left_delimiter = '<{';$tpl->right_delimiter = '}>';?>
a.html
<{$title}><br><{assign var="name" value="Bob"}><br /><{$name}><{assign var="content" value="abcd"}><br /><{$content}><{title num="10" content="aaaa" size="10"}><{title num="3" content="bbbb" size="7" }>//自定义:hello<font size=7>kkkkk</font><{hello num="5" size="2"}> 11111111111<{/hello}>
- 【smarty】smarty自定义函数
- 了解smarty自定义函数
- smarty自定义函数
- smarty自定义函数总结
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数1
- smarty自定义函数
- smarty中自定义函数
- smarty自定义函数
- smarty的自定义函数
- smarty自定义函数
- smarty 自定义函数
- SMARTY自定义函数总结
- smarty自定义函数
- smarty自定义函数
- smarty自定义函数
- 插入数据sql使用“insert into set”形式的理解
- Labview机器视觉(1)-安装配置
- wp7学习日记-1
- Android中的一个简单的List应用
- DIV高度自适应方法汇总
- smarty自定义函数
- Effective Java之接近理想的hashCode
- 记 Linux 学习知识总结 -- 寒江老师视频(三) 文件
- ACM打印图形
- phpcms2008同时发布到其他栏目
- Android开发之ListView 适配器(Adapter)优化
- 没有执行力,最牛逼的idea也只值20美元
- STL系列之一 deque双向队列
- 使用HTML5,CSS3和jQuery来增强网站的用户体验和使用乐趣