php smarty section使用
2024-10-19 00:33:47
文件:section.tpl
<html>
<head>
<title></title>
</head>
<body> {section name=color loop=$colors} {*这里是非关联数组,只是普通数组,这里的形式为:下标=>值 *} {$smarty.section.color.index} => {$colors[color]}<br> {/section} </body>
</html>
文件:section.php
<?php
require("Smarty.class.php");
$smarty = new Smarty();
$smarty -> template_dir = "./templates"; //模板存放目录
$smarty -> compile_dir = "./templates_c"; //编译目录
$smarty -> cache_dir = "./cache"; //缓存目录
$smarty -> config_dir = "./configs"; //缓存目录 $colors = array('红','黄','蓝');
$smarty -> assign('colors',$colors); $smarty -> display('section.tpl'); ?>
最新文章
- Steamroller
- php 获取中文长度 截取中文字符串
- SAP销售模块塑工常见问题和解决方案(自己收藏)
- inux grep 命令 搜索含有";zynq";字符的文件
- Python使用QRCode模块生成二维码
- javascript字符串截取的substring、substr和slice
- praise包--R给你点赞!
- Javascript模块化编程(三):require.js的用法【转】
- getComputedStyle(and currentStyle)
- Failed to execute command: ";";C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ResGen.exe"; 的一个解决办法
- 【HDOJ】4317 Unfair Nim
- 如何使用eclipse生成javadoc帮助文档
- STM32F4xx时钟理解
- MySQL日志文件之错误日志和慢查询日志详解
- 面向对象oop
- uva11636-Hello World!
- shell实战之Linux主机系统监控
- MySQL 存储过程的变量
- Excel文件数据导入到后台保存倒数据库
- angular bootstrap timepicker TypeError: Cannot set property &#39;$render&#39; of undefined
热门文章
- 【转】MyBatis学习总结(二)——使用MyBatis对表执行CRUD操作
- C#学习笔记10:Try-catch的用法和引用类型、值类型整理
- Android通过tcpdump抓包(wifi, 2g, 3g都可以)
- Spring切面处理
- Jquery inArray的使用
- ###STL学习--函数对象
- Linux用户级线程和内核级线程区别
- 轻松解决fedora21装完NVIDIA显卡驱动后无法进入gnome问题
- <;UNIX环境高级编程>;文件共享及fork函数
- 我忽略了的DOCTYPE!