Smarty comes with some built-in functions.
Built-in functions are part of the template language.
Users cannot create custom functions with the same name as built-in functions, nor can they modify built-in functions.
(insert, if, elseif, else , ldelim, rdelim, literal, php, section, sectionelse, strip and other built-in functions, please refer to the built-in function 2 of php template engine smarty)
#capture function
config_load
foreach, foreachelse
include
include_php
capture
Attribute Name Type Required Default Description
name string no default The name of the captured block
assign string No n/a The variable name where to assign the captured output to
Is the attribute type required? Default value description
name string no default Data collection area name
assign string No n/a Where is the data collection area assigned to the variable name [to be tested]
The function of the capture function is to capture the data output by the template and store it in a variable instead of outputting them to the page.
Any The data between {capture name="foo"} and {/capture} will be stored in the variable $foo, which is specified by the name attribute.
Access this variable in the template through $smarty.capture.foo.
If the name attribute is not specified, the function will use "default" as the parameter by default.
{capture} must appear in pairs, that is, end with {/capture}, and the function cannot be nested.
Example:
{* This example is in After capturing the content, output a row of tables containing data. If no data is captured, nothing will be output*}
{capture name=banner}
{include file="get_banner.tpl"}
{/capture}
{if $smarty .capture.banner ne ""}
{$smarty.capture.banner}
{/if}
config_load
from Loading variables in the configuration file
Whether the attribute type must have a default value description
file string Yes n/a The name of the configuration file to be included
section string No n/a The name of the section to be loaded in the configuration file
scope string no local Loading data The scope of the variable must be local, parent or global. local indicates that the scope of the variable is the current template. parent indicates that the scope of the variable is the current template and the parent template of the current template (the template that calls the current template). global Indicates that the scope of this variable is all templates.
global boolean No No Indicates whether the loaded variable is globally visible, equivalent to scope=parent. Note: When the scope attribute is specified, this attribute can be set, but the template ignores the attribute value and Subject to the scope attribute.
Example:
{config_load file="colors.conf"}

最近几年,PHP编程中的模板引擎已经成为了PHP开发的重要组成部分,方便了程序员进行页面开发和管理。本文将介绍PHP编程中常见的模板引擎。SmartySmarty是一个比较常用的PHP模板引擎,它支持缓存模板、插件模块和自定义函数等一系列功能。Smarty的语法十分灵活,能够解决PHP变量与HTML标记的结合难题,使得PHP语言更适用于模板化的设计。而且,S

Golang模板引擎入门指南:如何在Golang中使用模板,需要具体代码示例简介:模板引擎是一种能将数据和模板进行组合并生成HTML、文本或其他格式文档的工具。在Golang中,我们可以使用内置的模板包(html/template)来实现模板引擎的功能。本文将详细介绍如何在Golang中使用模板引擎,并提供具体的代码示例。一、模板引擎的基本概念在了解如何使用

ThinkPHP6模板引擎使用指南:打造精美的前端界面引言:随着Web应用程序的发展,前端界面的设计和开发变得愈发重要。作为一个开发人员,我们需要使用一个强大的模板引擎来帮助我们创建和管理前端界面。ThinkPHP6的模板引擎正是满足这一需求的强大工具。本文将介绍如何使用ThinkPHP6模板引擎来打造精美的前端界面。第一部分:安装ThinkPHP6模板引擎

Fat-Free框架是一个轻量级的PHP框架,旨在提供简单而灵活的工具来构建Web应用程序。它包含许多有用的功能,例如路由、数据库访问、缓存等。在Fat-Free框架中,使用Blade模板引擎可以帮助我们更方便地管理和渲染模板。Blade是Laravel框架中的模板引擎,它提供了强大的语法和模板继承功能。在本文中,我将演示如何在Fat-Free框架中使用Bl

随着互联网技术的发展,Web应用程序的需求也不断增加。Web开发人员通常使用模板引擎来生成动态网页。这篇文章将探讨一种新的模板引擎:Go语言模板引擎。什么是Go语言模板引擎?Go语言是由Google公司开发的一种先进的编程语言。它的语法简洁明了,易于学习和使用。Go语言模板引擎是Go语言中用于生成HTML模板的一种模板系统。Go语言模板引擎被称为"标准库",

PHP是一种广泛应用于Web开发的语言,无论是开发小型网站还是大型系统,PHP都是非常流行和方便的。在PHP开发过程中,我们需要将逻辑和数据层分离开来,这就需要使用到模板引擎。模板引擎可以简单地理解为将数据和模板文件合并,生成最终的HTML文件。在这篇文章中,我们将介绍一些PHP中可用的最佳模板引擎。SmartySmarty是PHP中最受欢迎的模板引擎之一,

在现代web开发中,前后端分离已经成为了一个非常流行的趋势,它能够让开发者们更好地组织项目并且提高了项目开发的效率。PHP和Smarty是两个非常常用的技术,它们可以用来实现前后端分离的开发方式。本文将会介绍如何使用PHP和Smarty来实现前后端分离开发。什么是前后端分离开发在传统的web开发中,前端主要负责页面的呈现以及与后端交互的逻辑。后端则主要负责业

现如今,网站的开发离不了一个重要的组成部分——模板引擎。模板引擎是指一种将页面模板和数据结合起来生成具有特定格式的html代码的工具。在各种网站开发框架中,模板引擎是一个必不可少的组件,因为模板引擎可以大量减少代码的重复性和提高页面的动态性。其中一种最常见和流行的模板引擎是Smarty。Smarty是一个基于PHP语言开发的DSL(DomainSpecif


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

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

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

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

WebStorm Mac version
Useful JavaScript development 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),
