The allocation data type of smarty template engine
This article mainly introduces the allocation data type of smarty template engine, and analyzes the usage skills of smarty template engine data type with examples. For reference value, friends in need can refer to it
The example in this article describes the usage of allocated data types by smarty template engine. Share it with everyone for your reference. The specific analysis is as follows:
1. Distribute basic data
?
3 4 6 7
8 9
|
//Assign basic data
$smarty->assign("str","hello smarty!");
$smarty->assign("int",143);
$smarty->assign("double",12.1344);
$smarty->assign("bool",true);
$smarty->assign("bool2",false);
String type: Integer type: Floating point type: Boolean type true: Boolean type false: |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | //Index array $res=array('Shanghai','Beijing','Shenzhen'); $smarty->assign("arr",$res); //Associative array $res2=array('city1'=>'Beijing','city2'=>'Guangzhou','city3'=>'Hunan'); $smarty->assign("arr2",$res2); //Index two-dimensional array $res3 = array( array('Xiaoxiao','Changshan','Wu Bei'), array('Shanshan','Changming') ); $smarty->assign("arr3",$res3); //Associated two-dimensional array $res4 = array( array('id'=>'001','name'=>'Zhang San','email'=>'zhangsan@1163.com'), array('url'=>'http://www.baidu.com','age'=>'28') ); $smarty->assign("arr4",$res4); //Associated two-dimensional array 2 $res5=array( 'emp1'=>array('id'=>'001','name'=>'Zhang San','email'=>'zhangsan@1163.com'), 'emp2'=>array('url'=>'http://www.baidu.com','age'=>'28') ); $smarty->assign("arr5",$res5); |
Template file
?
3 4 6
7 8
|
Index array: Element 1: , Element 2: , Element 3: Associative array method 1 (not recommended): Element 1: , Element 2: , Element 3:< ;{$arr2['city3']}> Associative array selection method 2 (recommended): Element 1: , Element 2: , Element 3: Two-dimensional index array: Element 1:, Element 2:, Element 3:, Element 4:, Element 5: Associative two-dimensional array form 1: id-, name-, email-, url-, age- Associative two-dimensional array form 2: id-, name-, email-, url-, age- |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | class Master{ var $name; var $age; function __construct($name,$age){ $this->name=$name; $this->age=$age; } } class Dog{ var $name; var $age; var $color; var $arr; var $master; function __construct($name,$age,$color,$arr6,$master){ $this->name=$name; $this->age=$age; $this->color=$color; $this->arr=$arr6; $this->master=$master; } } $arr6=array('001','002','003'); $master = new Master('Xiao Ming',22); $dog1 = new Dog('小白',1,'white',$arr6,$master); $smarty->assign("dog",$dog1); |
Template file
?
3 4 6 7 8 |
Object: //Basic attributes name-name}>, age-age}>,
color-color}> //Array attribute arr-arr[0]}>, arr-arr[1]}>, arr-arr[2]}> //Object properties object-master->name}>, object-master->age}> |

关于PPT蒙版,很多人肯定对它很陌生,一般人做PPT不会将它吃透,而是凑活着可以做出来自己喜欢的就行,所以很多人都不知道PPT蒙版到底是什么意思,也不知道这个蒙版有什么作用,甚至更不知道它可以让图片变得不再那么单调,想要学习的小伙伴们快来了学习学习,为你的PPT图片上添上点吧PPT蒙版吧,让它不再单调了。那么,PPT蒙版要怎么添上呢?请往下看。1.首先我们打开PPT,选择一张空白的图片,之后右键点击【设置背景格式】,纯色选择颜色就行。2.点击【插入】,艺术字,输入字3.点击【插入】,点击【形状】

C++模板特化影响函数重载和重写:函数重载:特化版本可提供特定类型不同的实现,从而影响编译器选择调用的函数。函数重写:派生类中的特化版本将覆盖基类中的模板函数,影响派生类对象调用函数时的行为。

您是否知道使用模板可以提高记笔记的速度以及捕捉重要想法的效率?OneNote有一套现成的模板供您使用。最好的部分是您还可以根据需要设计模板。无论您是学生、企业战士还是从事创造性工作的自由职业者。OneNote模板可用于以适合您风格的结构和格式记录重要笔记。模板可以是记笔记过程的大纲。业余爱好者只是做笔记,专业人士则在模板的帮助下通过结构良好的笔记做笔记并从中汲取联系。让我们看看如何在OneNote中使用模板。使用默认OneNote模板第1步:按键盘上的Windows+R。键入Oneno

PHP电子邮件模板:定制化和个性化您的邮件内容随着电子邮件的普及和广泛应用,传统的邮件模板已经不能满足人们对个性化和定制化邮件内容的需求。现在,我们可以通过使用PHP编程语言来创建定制化和个性化的电子邮件模板。本文将为您介绍如何使用PHP来实现这一目标,并提供一些具体的代码示例。一、创建邮件模板首先,我们需要创建一个基本的邮件模板。这个模板可以是一个HTM

Flask-Bootstrap:为Flask应用程序添加模板Flask是一个轻量级的PythonWeb框架,它提供了一个简单而灵活的方式来构建Web应用程序。它是一款非常受欢迎的框架,但它的默认模板功能有限。要创建富有吸引力的用户界面,需使用其他框架或库。这就是Flask-Bootstrap的用武之地。Flask-Bootstrap是一个基于Twitter

Vue中如何实现图片的模板和蒙版处理?在Vue中,我们经常需要对图片进行一些特殊的处理,例如添加模板效果或者加上蒙版。本文将介绍如何使用Vue实现这两种图片处理效果。一、图片模板处理在使用Vue处理图片时,我们可以利用CSS的filter属性来实现模板效果。filter属性给元素添加图形效果,其中的brightness滤镜可以改变图片的亮度。我们可以通过改变

C++是一门广泛应用于各个领域的编程语言,其模板元编程是一种高级编程技术,可让程序员在编译时对类型和数值进行变换。在C++中,模板元编程是一个广泛讨论的话题,因此在面试中,与此相关的问题也是相当常见的。以下是一些可能会被问到的C++中的模板元编程面试常见问题。什么是模板元编程?模板元编程是一种在编译时操作类型和数值的技术。它使用模板和元函数来根据类型和值生成

一甜相机中可以收藏很多的模版,那么收藏的模版位置在什么地方呢?用户们需要点击修图,在里面能够看到很多模版,找到有图标的模版就是收藏的模版,这篇收藏的模板位置介绍就能够告诉大家具体的内容,下面就是详细的介绍,赶紧来看看吧。一甜相机使用教程一甜相机收藏的模板在哪里答:在修图里能够看到自己收藏的模版具体方法:1、首先在软件里点击修图功能。2、在上面能够看到很多的模版。3、在里面能够看到有星的符号,就能找到收藏的模版。


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version
SublimeText3 Linux latest version

Notepad++7.3.1
Easy-to-use and free code editor

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Dreamweaver CS6
Visual web development tools
