Home  >  Article  >  Backend Development  >  ThinkPHP模板判断输出Empty标签用法详解_PHP

ThinkPHP模板判断输出Empty标签用法详解_PHP

WBOY
WBOYOriginal
2016-06-01 11:51:561161browse

ThinkPHP

ThinkPHP模板的empty标签用于判断模板变量是否为空值。

ThinkPHP模板empty标签用来判断模板变量是否为空值,其功能相当于PHP中的empty()函数行为。empty标签使用格式如下:

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

具体用法如下例所示:

<empty name="username">username 为空值</empty

该例子等同于:

<&#63;php
if(empty($username)){
  echo 'username 为空值';
}
&#63;>

如果判断非空值可使用notempty标签,如下所示:

<notempty name="username">username 不为空</notempty>

两个标签合并起来可写成:

<empty name="username">username 为空值<else/>username 不为空</empty>
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