ThinkPHP template range judgment output In tag and Range tag usage

不言
Release: 2023-03-30 09:46:01
Original
1830 people have browsed it

This article mainly introduces the usage of the In tag and the Range tag of the ThinkPHP template range judgment output. Friends who need it can refer to the

The in tag and range tag of the ThinkPHP template are used tojudge a certain template. Whether the variable is within a certain range.
1.in tag
ThinkPHP’s in tag is used to determine whether a template variable is within a certain range. The format is as follows:

要输出的内容
Copy after login

When used, in the module Set variables in operations (such as Index/display) and assign values ​​to the template:

$groupId = 1;
$this->assign( "groupId", $groupId );
Copy after login

Template/Tpl/default/Index/display.html, use the in tag as follows:

管理群组
Copy after login

Run the Example, can output:

Management Group

The php code of this example is equivalent to:

Copy after login

Note: The value of the variable can also be a string or array , the value of the value attribute can use variables.

2.notin tag

There is also a notin tag corresponding to the in tag, which means it is judged not to be within a certain range:
Usage such as:

非管理群组
Copy after login

The above two tag examples combined are equivalent to:

管理群组非管理群组
Copy after login

3.range tag

ThinkPHP’s in and notin tags can also be used range tag instead, such as:

管理群组
Copy after login

The above example is equivalent to the in tag. When the value of the type attribute is notin, it is equivalent to the notin tag.

Related recommendations:

How to use thinkPHP’s Html template tag

ThinkPHP template judgment output Empty tag usage

The above is the detailed content of ThinkPHP template range judgment output In tag and Range tag usage. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!