Home > Backend Development > PHP Tutorial > ThinkPHP template determines the usage of output Empty tag

ThinkPHP template determines the usage of output Empty tag

不言
Release: 2023-03-30 09:34:02
Original
3126 people have browsed it

This article mainly introduces the usage of the Empty tag in ThinkPHP template judgment output. Friends who need it can refer to

The empty tag of ThinkPHP template is used to judge whether the template variable is empty.

ThinkPHP template empty tag is used to determine whether the template variable is empty. Its function is equivalent to the empty() function behavior in PHP. The format of the empty tag is as follows:

<empty name="变量名">要输出的内容</empty>
Copy after login

The specific usage is as shown in the following example:

<empty name="username">username 为空值</empty
Copy after login

This example is equivalent to:

<?php
if(empty($username)){
  echo &#39;username 为空值&#39;;
}
?>
Copy after login

If you judge a non-empty value, you can use the notempty tag, as follows Shown:

<notempty name="username">username 不为空</notempty>
Copy after login

The two tags can be combined to write:

<empty name="username">username 为空值<else/>username 不为空</empty>
Copy after login

##Related recommendations:

ThinkPHP Template variable output, custom functions and judgment statement usage

The above is the detailed content of ThinkPHP template determines the usage of output Empty tag. 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