


Using ordinary tags for variable output is enough, but other controls and loops must be completed and judgment function, you need to use the tag library function of the template engine . All tags in the system built-in tag library can be used directly without introducing the tag library.
Closed tag:
<include file="read" />
Open tag:
<gt name="name" value="5">value</gt>Built-in support The list of tags and
attributes is as follows:
tag name |
function |
contains attributes |
include |
include external templates File (closed) |
file |
import |
import resource file (closed include js css load alias) |
file,href,type,value ,basepath |
volist |
looparraydata output |
name,id,offset,length,key,mod |
Array or object traversaloutput |
name,item,key |
|
for | For loop data output |
name,from,to,before,step |
branch judgment output |
name |
|
case |
Branch judgment output (must be used with switch) |
value, break |
default |
default output (closed must be used with switch) |
None |
compare |
Compare output (including aliases such as eq neq lt gt egt elt heq nheq) | name,value,type |
Range judgment output (including in notin between notbetween aliases) |
name,value,type |
|
present |
Determine whether a value has been assigned |
name |
notpresent |
Determine whether a value has not yet been assigned | name |
empty |
Determine whether the data is empty |
name |
notempty |
Determine whether the data is not empty |
name |
defined |
Determine whether the constant is defined |
name |
notdefined | Determine whether the constant is undefined |
name |
define |
Constant definition (closed) |
name,value |
assign |
Variable assignment (closed ) |
name,value |
conditional judgmentoutput |
condition |
|
elseif |
Conditional judgment output (closed must be used with the if tag) |
condition |
else |
condition is not established output (closed can be used for other Tags) |
none |
php |
using php code |
none |
1.include
You can use the Include tag to include external The template file is used as follows:
include tag (including external template file) | |
closed |
closed tag |
Properties |
file (required): template file to be included, supports variables |
示例:
1、 使用完整文件名包含
格式:
<include file="完整模板文件名" />
例如:
<include file="./Tpl/default/Public/header.html" />
这种情况下,模板文件名必须包含后缀。使用完整文件名包含的时候,特别要注意文件包含指的是服务器端包含,而不是包含一个URL地址,也就是说file参数的写法是服务器端的路径,如果使用相对路径的话,是基于项目的入口文件位置。
2、包含当前模块的其他操作模板文件
格式:
<include file="操作名" />
例如 导入当前模块下面的read操作模版:
<include file="read" />
操作模板无需带后缀。
3、 包含其他模块的操作模板
格式:
<include file="模块名:操作名" />
例如,包含Public模块的header操作模版:
<include file="Public:header" />
4、包含其他模板主题的模块操作模板
格式:
<include file="主题名:模块名:操作名" />
例如,包含blue主题的User模块的read操作模版:
<include file="blue:User:read" />
5、 用变量控制要导入的模版
格式:
<include file="$变量名" />
例如
<include file="$tplName" />
给$tplName赋不同的值就可以包含不同的模板文件,变量的值的用法和上面的用法相同。
无论你使用什么方式包含外部模板,Include标签支持在包含文件的同时传入参数,例如,下面的例子我们在包含header模板的时候传入了title和keywords变量:
<include file="header" title="ThinkPHP框架"keywords="开源WEB开发框架"/>
就可以在包含的header.html文件里面使用var1和var2变量,方法
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>[title]</title> <meta name="keywords" content="[keywords]" /> </head>
注意:由于模板解析的特点,从入口模板开始解析,如果外部模板有所更改,模板引擎并不会重新编译模板,除非在调试模式下或者缓存已经过期。如果部署模式下修改了包含的外部模板文件后,需要把模块的缓存目录清空,否则无法生效。
以上就是thinkphp常用内置标签include的详解的内容,更多相关内容请关注PHP中文网(www.php.cn)!

What’s still popular is the ease of use, flexibility and a strong ecosystem. 1) Ease of use and simple syntax make it the first choice for beginners. 2) Closely integrated with web development, excellent interaction with HTTP requests and database. 3) The huge ecosystem provides a wealth of tools and libraries. 4) Active community and open source nature adapts them to new needs and technology trends.

PHP and Python are both high-level programming languages that are widely used in web development, data processing and automation tasks. 1.PHP is often used to build dynamic websites and content management systems, while Python is often used to build web frameworks and data science. 2.PHP uses echo to output content, Python uses print. 3. Both support object-oriented programming, but the syntax and keywords are different. 4. PHP supports weak type conversion, while Python is more stringent. 5. PHP performance optimization includes using OPcache and asynchronous programming, while Python uses cProfile and asynchronous programming.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP originated in 1994 and was developed by RasmusLerdorf. It was originally used to track website visitors and gradually evolved into a server-side scripting language and was widely used in web development. Python was developed by Guidovan Rossum in the late 1980s and was first released in 1991. It emphasizes code readability and simplicity, and is suitable for scientific computing, data analysis and other fields.

PHP is suitable for web development and rapid prototyping, and Python is suitable for data science and machine learning. 1.PHP is used for dynamic web development, with simple syntax and suitable for rapid development. 2. Python has concise syntax, is suitable for multiple fields, and has a strong library ecosystem.

PHP remains important in the modernization process because it supports a large number of websites and applications and adapts to development needs through frameworks. 1.PHP7 improves performance and introduces new features. 2. Modern frameworks such as Laravel, Symfony and CodeIgniter simplify development and improve code quality. 3. Performance optimization and best practices further improve application efficiency.

PHPhassignificantlyimpactedwebdevelopmentandextendsbeyondit.1)ItpowersmajorplatformslikeWordPressandexcelsindatabaseinteractions.2)PHP'sadaptabilityallowsittoscaleforlargeapplicationsusingframeworkslikeLaravel.3)Beyondweb,PHPisusedincommand-linescrip

PHP type prompts to improve code quality and readability. 1) Scalar type tips: Since PHP7.0, basic data types are allowed to be specified in function parameters, such as int, float, etc. 2) Return type prompt: Ensure the consistency of the function return value type. 3) Union type prompt: Since PHP8.0, multiple types are allowed to be specified in function parameters or return values. 4) Nullable type prompt: Allows to include null values and handle functions that may return null values.


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

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

Hot Article

Hot Tools

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

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

Zend Studio 13.0.1
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools

MantisBT
Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.