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

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

WBOY
Release: 2016-06-01 11:51:56
Original
1224 people have browsed it

ThinkPHP

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

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

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

具体用法如下例所示:

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

该例子等同于:

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

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

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

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

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