Content to output"."/> Content to output".">

Home  >  Article  >  PHP Framework  >  How to determine whether a variable is empty in thinkphp5

How to determine whether a variable is empty in thinkphp5

WBOY
WBOYOriginal
2022-04-07 15:50:063422browse

In thinkphp, you can use the empty tag to determine whether a variable is empty. The function of this tag is to determine whether a template variable is empty. Its function is equivalent to the empty() function in PHP, and the syntax is "fac2daa36aeb688e55bc0c64111563bcContent to be outputb9068ac49ba4bb88208133fa713e1c95".

How to determine whether a variable is empty in thinkphp5

The operating environment of this article: Windows 10 system, ThinkPHP version 5, Dell G3 computer.

thinkphp5 determines whether the 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 empty tag usage format is as follows:

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

The specific usage is as shown in the following example:

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

This example is equivalent to:

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

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

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

The two tags can be combined to write:

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

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to determine whether a variable is empty in thinkphp5. For more information, please follow other related articles on the PHP Chinese website!

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