文件: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'); ?>

php smarty section使用的更多相关文章

  1. smarty section 循环不同的四个样式

    <div class="moban_spzs"> <{section name=goodslist loop=$strdata6}> <{if $sm ...

  2. Smarty section、foreach控制循环次数的实现详解

    <!--{ section name='i' loop=$a }--><!--{ if $smarty.section.i.index < 3 }--><!--{  ...

  3. smarty模板引擎中section循环loop与total的区别

    在smarty模板引擎的section循环中 $data=[101,102,103,105,104]; section的两个属性total与loop {section foo $data start= ...

  4. Smarty中section的使用

     在smarty的使用过程中,有很多时候需要将一个数组输出到模板中来处理,以下将演示如何将一个索引(index)数组和关联(assocaite)数组在页面中展现出来. 本文中假设有如下一个索引数组 1 ...

  5. PHP模板引擎Smarty内建函数section,sectionelse用法详解

    本文实例讲述了PHP模板引擎Smarty内建函数section,sectionelse用法.分享给大家供大家参考,具体如下: section 是 Smarty 模板中除了 foreach 以外的另一种 ...

  6. 12月15日smarty模板基本语法

    smarty基本语法: 1.注释:<{* this is a comment *}>,注意左右分隔符的写法,要和自己定义的一致. <{* I am a Smarty comment, ...

  7. SMARTY模板中如何使用get,post,request,cookies,session,server变量

    {$smarty}保留变量不需要从PHP脚本中分配,是可以在模板中直接访问的数组类型变量,通常被用于访问一些特殊的模板变量.例如,直接在模板中访问页面请求变量.获取访问模板时的时间戳.直接访问PHP中 ...

  8. Smarty模板技术学习

    模板引擎技术:使得php代码和html代码分离的技术就称为"模板引擎技术" 自定义smarty模板技术实现 <?php //迷你smarty原理 class MiniSmar ...

  9. smarty基本语法

    smarty基本语法: 1.注释:<{* this is a comment *}>,注意左右分隔符的写法,要和自己定义的一致. <{* I am a Smarty comment, ...

随机推荐

  1. 使用adb devices命令,老是报error:device offline的错误。

    刚开始报error:devices not found 重新安装adb 驱动. 解决方法: adb kill-server adb start-server adb remount 再使用adb de ...

  2. 学习笔记4_ServletContext(重要整个Web应用的动态资源之间共享数据)

    ServletContext(重要) 一个项目只有一个ServletContext对象! 我们可以在N多个Servlet中来获取这个唯一的对象,使用它可以给多个Servlet传递数据! 与天地同寿!! ...

  3. web前端面试题收集(一)

    CSS中margin和padding的区别? Javascript中如何检测一个变量是一个String类型?请写出函数实现. 网页中实现一个计算当年还剩多少时间的倒计时程序,要求网页上实时动态显示“x ...

  4. 在Windows下基于libx264.a的Qt 4.8.2视频压缩

    1.在用mingw 4.5.2编译x264后,生成libx264.a文件,将libx264.a和x264.h和x264_config.h拷贝到Qt工程中,将mingw/lib/libpthread.a ...

  5. MFC GDI相关对象

    首先说明几个名词: CDC 是MFC对Wind32 API的设备上下文(DC)进行封装的C++类,由他继承的类包括 CPaintDC(常用)CWindowDC(现在软件基本不用) CClientDC( ...

  6. Arrays 标准库算法

    Binary Search public static int binarySearch0(Object[] a, int fromIndex, int toIndex, Object key) { ...

  7. SharePoint工作流(workflow)不能自动启动

    在定制工作流时,设置了当Item创建或更改时,触发工作流.用系统帐户登录时一直不会触发.这是因为这是SharePoint的安全机制,阻止了在系统帐户登陆时自动启动工作流. 解决方法:使用不是系统账户的 ...

  8. 实时监听input输入框value值的变化

    1.js 的 oninput & onpropertychange JS中的 oninput 事件在 IE9 以下版本不支持,需要使用 IE 特有的 onpropertychange 事件替代 ...

  9. C#基础(三)—重载与覆盖

    所谓重载指的是同一个类中有两个或多个名字相同但是参数不同的方法.重载,必然发生在一个类中,函数名相同,参数类型或者顺序不同构成重载,与返回类型无关. override:过载也称重写是指子类对父类中虚函 ...

  10. demo_01 css3中的radius

    css属性:border-radius :border:边框:radius:弧度:所以这个属性的意思很明了. 下面实现一个小demo: <!doctype html> <html&g ...