Smarty模板技术-自定义函数-1
来源:互联网 发布:皇室战争电磁炮数据 编辑:程序博客网 时间:2024/04/30 11:47
1.PHP文件内容
注:本文代码均出自瓢城Web俱乐部李炎恢老师Smarty教学视频,仅供学习和研究使用
<?php require_once '../smarty.inc.php'; global $smarty; $smarty->assign('title' , 'Smarty模板引擎之自定义函数'); $smarty->assign('table' , array(1,2,3,4,5,6)); $smarty->assign('x' ,100); $smarty->assign('y',3); $smarty->assign('opt' , array('a'=>1 , 'b'=>2 , 'c'=>3 , 'd'=>4)); $smarty->assign('id' , 'c'); $smarty->display('index.html');
1.模板文件内容
<!doctype html><html> <head> <meta charset="utf-8"> <title>{$title}</title> </head> <body> {* 模板自定义属性 *} {* assign 用于在模板被执行时,为变量赋值 *} {assign var='mail' value='173000950@qq.com'} mail:{$mail} <br /> {* counter 用于输出一个计数过程 *} {counter start=5 skip=2 direction=down } | {counter print=false} | {counter assign=c} {$c} {* cycle 轮换使用一组数据 *} <p style="background:{cycle values='red,green'}">1</p> <p style="background:{cycle values='red,green'}">1</p> {* debug 可以查看模板各个信息 *} {debug} {* eval 用于显示普通变量和配置变量 *} {eval var=$title assign=c} {$c} {* fetch 引入其他文件的原代码 *} {fetch file='http://www.onlycat.cc'} {* html_image 创建一张图片 *} {html_image file="http://www.onlycat.cc/img/search.png" alt="来自猫先生的图" width="100px" height="100px" href="http://www.onlycat.cc"} {* html_table 显示表格 *} {html_table loop=$table cols=3} {* math 进行模板计算 *} {math equation=$x*$y} {* mailto 创建电子邮件链接 *} {mailto address="173000950@qq.com" text='onlycat'} {* textformat 文字格式化 *} {textformat indent=20} onlycat {/textformat} {* html_checkboxes 批量显示复选框 *} {html_checkboxes options=$opt checked=$id} {* html_radios 批量显示单选择框 *} {html_radios options=$opt checked=$id} {* html_options 下拉菜单 *} <select> {html_options options=$opt selected=$id} </select> {* html_select_date 显示日期的下拉列表 *} {html_select_date month_format='%m' field_order=YMD start_year=1999 } {* html_select_time 显示时间的下拉列表 *} {html_select_time} </body></html>
0 0
- Smarty模板技术-自定义函数-1
- Smarty模板技术-自定义函数-2
- Smarty模板技术-内置函数
- smarty自定义函数1
- 1. smarty 模板技术(1)
- PHP模板学习--Smarty 自定义函数
- smarty模板引擎_7-自定义函数
- smarty模板引擎_7-自定义函数
- 【smarty】smarty自定义函数
- Smarty模板技术-Smarty安装
- Smarty模板技术-Smarty变量
- smarty自定义引擎模板
- smarty自定义模板
- smarty模板技术
- PHP模板技术Smarty
- Smarty模板技术基础知识
- Smarty模板技术
- Smarty模板技术
- WordPress 3.6-4.5.2 Authenticated Revision History Information Disclosure
- 第九天:JAVA中的多态,抽象类和接口
- Maven项目中,将普通工程修改为web工程办法
- Error:Unable to start the daemon process.解决
- FPGA学习:VHDL设计灵活性&不同设计思路比较
- Smarty模板技术-自定义函数-1
- Word Rings POJ2949 (Bellman-ford算法,找平均值最大的环)
- centOS7开机直接进入命令界面
- 简单排序(1)
- 我的见解之hibernate(三)
- php之static后期绑定/延迟绑定
- 我的博客
- 三种经典的递归-java
- RedisCluster 安装