文件: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. hasLayout与Block formatting contexts的学习(下)

    BFC布局规则: 内部的Box会在垂直方向,一个接一个地放置. Box垂直方向的距离由margin决定.属于同一个BFC的两个相邻Box的margin会发生重叠 每个元素的margin box的左边, ...

  2. Ubuntu 16.04 - 64bit 解压 rar 报错 Parsing Filters not supported

    Ubuntu 16.04 - 64bit  解压rar 文件报错: 错误如下图: 原因: 未安装解压命令 unrar 参考博客: Error - "Parsing Filters not s ...

  3. Opencv——将摄像头拍摄写成视频文件

    这里主要利用了Opencv打开摄像头的代码,以及写入视频的函数,只是这里要注意的是摄像头好像没有帧率,在cvCreateVideoWriter,时要自己设置 #include"cv.h&qu ...

  4. C语言对文件的相关命令

    fopen(文件名,使用文件的方式):打开数据文件 fclose(FILE *fp):关闭数据文件 feof(FILE *fp):是判断是否到fp的结尾 fputc(char ch,FILE *fp) ...

  5. IOS之KVC机制(Object-C篇)

    开发环境:xcode7 一.KVC概述 1.KVC是KeyValueCoding的简称,它是一种可以直接通过类属性的名字来作key,再绑定key的值来访问类属性的机制,而不再通过利用@property ...

  6. iOS App Transport Security

    网络请求提示:Application Transport Security has blocked a cleartext HTTP (http://) resource load since it ...

  7. CSS FIXED porn javhd

    CSS position property - W3Schools W3Schools › cssref › pr_class_position Definition and Usage. The p ...

  8. Chrome 建立SOCKS5代理

    前提是putty已经在7090端口和远程服务器建立隧道. 假设你的chrome浏览器位于"C:\Program Files (x86)\Google\Chrome\Application\c ...

  9. jQuery实例-简单选项卡-【一些常见方法(2)-练习】

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  10. linux定时执行php脚本

    1.查看lynx命令所在的路径 whereis lynx 或者 which lynx 如果没有,则安装 yum install lynx 或者 apt-get方式(ubuntu) 2.建立 shell ...