Home Backend Development PHP Tutorial ThinkPHP template judgment output Defined tag usage detailed explanation_PHP tutorial

ThinkPHP template judgment output Defined tag usage detailed explanation_PHP tutorial

Jul 13, 2016 am 10:26 AM
thinkphp Label template

The defined tag of the ThinkPHP template engine is used to determine whether the constant has been defined .
ThinkPHP's defined tag is used to determine whether a constant has been defined. Its function is equivalent to the defined() function in PHP. The defined tag is used as follows:

<present name="常量">要输出的内容</present>
Copy after login

First define a constant in the module operation (such as: Index/display) and output the template:

define("SITE_NAME", "脚本之家");
$this->display();
Copy after login

Use the defined tag in template/Tpl/default/Index/display.html as follows:

<defined name="SITE_NAME">网站名称:{*SITE_NAME}</defined>
Copy after login

Running this example will output:

网站名称:脚本之家
Copy after login

The equivalent PHP code for this example is as follows:

<?php
if(defined("SITE_NAME")){
  echo '网站名称:',constant("SITE_NAME");
}
?>
Copy after login

If the judgment is not defined, you can use:

<notdefined name="SITE_NAME">{*SITE_NAME}不存在活未定义</notdefined>
Copy after login

The above two examples are combined as follows:

<defined name="SITE_NAME">网站名称:{*SITE_NAME}<else/>{*SITE_NAME}不存在活未定义</defined>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/824720.htmlTechArticleThe defined tag of ThinkPHP template engine is used to determine whether the constant has been defined. ThinkPHP's defined tag is used to determine whether a constant has been defined. Its function is equivalent to defin in PHP...
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to run thinkphp project How to run thinkphp project Apr 09, 2024 pm 05:33 PM

How to run thinkphp project

There are several versions of thinkphp There are several versions of thinkphp Apr 09, 2024 pm 06:09 PM

There are several versions of thinkphp

How to search for text across all tabs in Chrome and Edge How to search for text across all tabs in Chrome and Edge Feb 19, 2024 am 11:30 AM

How to search for text across all tabs in Chrome and Edge

How to run thinkphp How to run thinkphp Apr 09, 2024 pm 05:39 PM

How to run thinkphp

How to install thinkphp How to install thinkphp Apr 09, 2024 pm 05:42 PM

How to install thinkphp

Which one is better, laravel or thinkphp? Which one is better, laravel or thinkphp? Apr 09, 2024 pm 03:18 PM

Which one is better, laravel or thinkphp?

How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to? How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to? Mar 22, 2024 am 10:28 AM

How to add tags on Douyin to attract traffic? Which tags on the platform are easiest to attract traffic to?

How to add PPT mask How to add PPT mask Mar 20, 2024 pm 12:28 PM

How to add PPT mask

See all articles