search
HomeBackend DevelopmentPHP Tutorialdestoon二次开发模板及调用语法汇总_php实例

一、模板存放及调用规则

模板存放于系统 template 目录,template 目录下的一个目录
例如:template/default/ 即为一套模板

模板文件以 .htm 为扩展名,可直接存放于模板目录
例如 template/default/index.htm
也可以存放于模板目录的子目录里
例如:template/default/member/index.htm

在PHP文件里,使用模板语法为

<&#63;php
 include template('index');
&#63;>

或者

<&#63;php
 include template('index', 'member');
&#63;>

如果当前默认模板套系为default,则:

<&#63;php
 include template('header');
&#63;>

表示使用 template/default/header.htm 模板文件

<&#63;php
 include template('header', 'member');
&#63;>

表示使用 template/default/member/header.htm 模板文件

模板目录下在 these.name.php 是模板别名的配置文件,模板别名可以在后台模板管理修改。

模板解析后的缓存文件保存于cache/tpl/目录,扩展名为 .tpl.php

二、模板语法

1、包含模板:{template 'header'} 或{template 'header', 'member'}

{template 'header'}被解析为

<&#63;php
 include template('header');
&#63;>

表示使用 template/default/header.htm 模板文件

{template 'header', 'member'}

被解析为:

<&#63;php
 include template('header','member');
&#63;>

表示使用 template/default/member/header.htm 模板文件

2、变量或常量表示:

变量 {$destoon} 被解析为:

<&#63;php
 echo $destoon;
&#63;>

常量 {DESTOON} 被解析为:

<&#63;php
 echo DESTOON;
&#63;>

对于数组,标准写法应为 例如 {$destoon['index']},可简写为{$destoon[index]},模板在解析时会自动追加引号。

3、函数 {func_name($par1, $par2)}

{func_name($par1, $par2)}被解析为

<&#63;php
 func_name($par1, $par2);
&#63;>

4、PHP表达式 {php expression}

{php expression}被解析为

<&#63;php
 expression 
&#63;>

5、条件语句 {if $a=='b'} do A {/if} 或{if $a=='b'} do A {else} do B {/if} 或 {if $a=='b'} do A{elseif $b=='c'} do C {else} do B {/if}

{if $a=='b'} do A {/if}被解析为

<&#63;php
 if($a=='b') {
 do A
 }
&#63;>

{if $a=='b'} do A {else} do B {/if}被解析为

<&#63;php
 if($a=='b') {
 do A 
 } else {
 do B
 } 
&#63;>

{if $a=='b'} do A {elseif $b=='c'} do C {else} do B {/if}被解析为

<&#63;php
 if($a=='b') {
 do A 
 } else if($b=='c') {
 do C
 } else {
 do B
 } 
&#63;>

6、LOOP循环 {loop $var $v}...{loop} 或

{loop $var $k $v}...{loop}

{loop $var $v}...{loop}被解析为

<&#63;php
 if(is_array($var)) {
 foreach($var as $v) {
 ... }
 }
&#63;>

{loop $var $k $v}...{loop}被解析为

<&#63;php
 if(is_array($var)) {
 foreach($var as $k=>$v) {
 ... }
 }
&#63;>

三、特殊用法

1、变量或表达式可以用HTML注释,例如 仍被解析为 (可自动过滤此类注释)

2、可直接在模板里书写PHP代码,直接书写PHP代码与DESTOON 模板语法是兼容的。

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
PHP Email: Step-by-Step Sending GuidePHP Email: Step-by-Step Sending GuideMay 09, 2025 am 12:14 AM

PHPisusedforsendingemailsduetoitsintegrationwithservermailservicesandexternalSMTPproviders,automatingnotificationsandmarketingcampaigns.1)SetupyourPHPenvironmentwithawebserverandPHP,ensuringthemailfunctionisenabled.2)UseabasicscriptwithPHP'smailfunct

How to Send Email via PHP: Examples & CodeHow to Send Email via PHP: Examples & CodeMay 09, 2025 am 12:13 AM

The best way to send emails is to use the PHPMailer library. 1) Using the mail() function is simple but unreliable, which may cause emails to enter spam or cannot be delivered. 2) PHPMailer provides better control and reliability, and supports HTML mail, attachments and SMTP authentication. 3) Make sure SMTP settings are configured correctly and encryption (such as STARTTLS or SSL/TLS) is used to enhance security. 4) For large amounts of emails, consider using a mail queue system to optimize performance.

Advanced PHP Email: Custom Headers & FeaturesAdvanced PHP Email: Custom Headers & FeaturesMay 09, 2025 am 12:13 AM

CustomheadersandadvancedfeaturesinPHPemailenhancefunctionalityandreliability.1)Customheadersaddmetadatafortrackingandcategorization.2)HTMLemailsallowformattingandinteractivity.3)AttachmentscanbesentusinglibrarieslikePHPMailer.4)SMTPauthenticationimpr

Guide to Sending Emails with PHP & SMTPGuide to Sending Emails with PHP & SMTPMay 09, 2025 am 12:06 AM

Sending mail using PHP and SMTP can be achieved through the PHPMailer library. 1) Install and configure PHPMailer, 2) Set SMTP server details, 3) Define the email content, 4) Send emails and handle errors. Use this method to ensure the reliability and security of emails.

What is the best way to send an email using PHP?What is the best way to send an email using PHP?May 08, 2025 am 12:21 AM

ThebestapproachforsendingemailsinPHPisusingthePHPMailerlibraryduetoitsreliability,featurerichness,andeaseofuse.PHPMailersupportsSMTP,providesdetailederrorhandling,allowssendingHTMLandplaintextemails,supportsattachments,andenhancessecurity.Foroptimalu

Best Practices for Dependency Injection in PHPBest Practices for Dependency Injection in PHPMay 08, 2025 am 12:21 AM

The reason for using Dependency Injection (DI) is that it promotes loose coupling, testability, and maintainability of the code. 1) Use constructor to inject dependencies, 2) Avoid using service locators, 3) Use dependency injection containers to manage dependencies, 4) Improve testability through injecting dependencies, 5) Avoid over-injection dependencies, 6) Consider the impact of DI on performance.

PHP performance tuning tips and tricksPHP performance tuning tips and tricksMay 08, 2025 am 12:20 AM

PHPperformancetuningiscrucialbecauseitenhancesspeedandefficiency,whicharevitalforwebapplications.1)CachingwithAPCureducesdatabaseloadandimprovesresponsetimes.2)Optimizingdatabasequeriesbyselectingnecessarycolumnsandusingindexingspeedsupdataretrieval.

PHP Email Security: Best Practices for Sending EmailsPHP Email Security: Best Practices for Sending EmailsMay 08, 2025 am 12:16 AM

ThebestpracticesforsendingemailssecurelyinPHPinclude:1)UsingsecureconfigurationswithSMTPandSTARTTLSencryption,2)Validatingandsanitizinginputstopreventinjectionattacks,3)EncryptingsensitivedatawithinemailsusingOpenSSL,4)Properlyhandlingemailheaderstoa

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Safe Exam Browser

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.

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)